如何构建库比蒂诺文字菲尔德

发布于 2025-02-04 19:26:41 字数 227 浏览 3 评论 0原文

我该如何在扑朔迷离中取得这样的成就? 我说的是格雷上的2个textfield。他们是Cupertino Textfield吗?

How can I achieve something like this in Flutter?
I am talking about the 2 textfield on grey. Are they a Cupertino Textfield?

textfield

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧伤慢歌 2025-02-11 19:26:41

使用

 Container(
        padding: EdgeInsets.all(8),
        height: 100,
        width: 300,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(20),
          color: Colors.grey.shade300,
        ),
        child: Column(
          children: [
            CupertinoTextField(
              placeholder: 'Required',
              prefix: Text(
                'Name',
                style: TextStyle(
                  fontWeight: FontWeight.bold,
                ),
              ),
              decoration: BoxDecoration(),
            ),
            Divider(
              thickness: 1,
              color: Colors.grey,
            ),
            CupertinoTextField(
              prefix: Text(
                'Card Number',
                style: TextStyle(
                  fontWeight: FontWeight.bold,
                ),
              ),
              decoration: BoxDecoration(),
            ),
          ],
        ),
      ),

结果屏幕 - >

使用 /strong>

  Container(
        padding: EdgeInsets.all(8),
        height: 135,
        width: 300,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(20),
          color: Colors.grey.shade300,
        ),
        child: Column(
          children: [
            TextField(
              decoration: new InputDecoration(
                prefixIcon: Padding(
                  padding: EdgeInsets.only(
                    top: 15,
                  ),
                  child: Text(
                    'Name',
                    style: TextStyle(
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
                border: InputBorder.none,
                focusedBorder: InputBorder.none,
                enabledBorder: InputBorder.none,
                errorBorder: InputBorder.none,
                disabledBorder: InputBorder.none,
                hintText: "Required",
              ),
            ),
            Divider(
              thickness: 1,
              color: Colors.grey,
            ),
            TextField(
              decoration: new InputDecoration(
                prefixIcon: Padding(
                  padding: EdgeInsets.only(
                    top: 15,
                    right: 10,
                  ),
                  child: Text(
                    'Card Number',
                    style: TextStyle(
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
                border: InputBorder.none,
                focusedBorder: InputBorder.none,
                enabledBorder: InputBorder.none,
                errorBorder: InputBorder.none,
                disabledBorder: InputBorder.none,
              ),
            ),
          ],
        ),
      ),

结果屏幕 - >

Try below code

Using CupertinoTextField

 Container(
        padding: EdgeInsets.all(8),
        height: 100,
        width: 300,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(20),
          color: Colors.grey.shade300,
        ),
        child: Column(
          children: [
            CupertinoTextField(
              placeholder: 'Required',
              prefix: Text(
                'Name',
                style: TextStyle(
                  fontWeight: FontWeight.bold,
                ),
              ),
              decoration: BoxDecoration(),
            ),
            Divider(
              thickness: 1,
              color: Colors.grey,
            ),
            CupertinoTextField(
              prefix: Text(
                'Card Number',
                style: TextStyle(
                  fontWeight: FontWeight.bold,
                ),
              ),
              decoration: BoxDecoration(),
            ),
          ],
        ),
      ),

Result Screen-> image

Using TextField

  Container(
        padding: EdgeInsets.all(8),
        height: 135,
        width: 300,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(20),
          color: Colors.grey.shade300,
        ),
        child: Column(
          children: [
            TextField(
              decoration: new InputDecoration(
                prefixIcon: Padding(
                  padding: EdgeInsets.only(
                    top: 15,
                  ),
                  child: Text(
                    'Name',
                    style: TextStyle(
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
                border: InputBorder.none,
                focusedBorder: InputBorder.none,
                enabledBorder: InputBorder.none,
                errorBorder: InputBorder.none,
                disabledBorder: InputBorder.none,
                hintText: "Required",
              ),
            ),
            Divider(
              thickness: 1,
              color: Colors.grey,
            ),
            TextField(
              decoration: new InputDecoration(
                prefixIcon: Padding(
                  padding: EdgeInsets.only(
                    top: 15,
                    right: 10,
                  ),
                  child: Text(
                    'Card Number',
                    style: TextStyle(
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
                border: InputBorder.none,
                focusedBorder: InputBorder.none,
                enabledBorder: InputBorder.none,
                errorBorder: InputBorder.none,
                disabledBorder: InputBorder.none,
              ),
            ),
          ],
        ),
      ),

Result Screen-> image

幸福还没到 2025-02-11 19:26:41

您可以使用Cupertinotextfield.borderless来满足您的要求。以下是一个示例:

Padding(
          padding: const EdgeInsets.all(8.0),
          child: Container(
            decoration: BoxDecoration(
                color: Colors.grey[400],
                borderRadius: BorderRadius.circular(10)),
            padding: const EdgeInsets.all(10),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: const [
                CupertinoTextField.borderless(
                  padding: EdgeInsets.only(left: 65, top: 10, right: 6, bottom: 10),
                  prefix: Text('Name'),
                  placeholder: 'Required',
                ),
                Divider(
                  thickness: 1,
                  color: Colors.black,
                ),
                CupertinoTextField.borderless(
                  padding: EdgeInsets.only(left: 15, top: 10, right: 6, bottom: 10),
                  prefix: Text('Card Number'),
                ),
              ],
            ),
          ),
        )

使用窗口小部件参数来根据自己的需求进行自定义。

You can use cupertinotextfield.borderless to meet your requirements. Here is an example:

Padding(
          padding: const EdgeInsets.all(8.0),
          child: Container(
            decoration: BoxDecoration(
                color: Colors.grey[400],
                borderRadius: BorderRadius.circular(10)),
            padding: const EdgeInsets.all(10),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: const [
                CupertinoTextField.borderless(
                  padding: EdgeInsets.only(left: 65, top: 10, right: 6, bottom: 10),
                  prefix: Text('Name'),
                  placeholder: 'Required',
                ),
                Divider(
                  thickness: 1,
                  color: Colors.black,
                ),
                CupertinoTextField.borderless(
                  padding: EdgeInsets.only(left: 15, top: 10, right: 6, bottom: 10),
                  prefix: Text('Card Number'),
                ),
              ],
            ),
          ),
        )

Play around with the widgets parameters to customise it to your own needs.

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文