【问题标题】:Prefix and suffix icon not showing without focus. Flutter TextField/Form [closed]没有焦点不显示前缀和后缀图标。 Flutter TextField/Form [关闭]
【发布时间】:2022-12-28 11:57:37
【问题描述】:

在我的TextField中,如果不关注TextField,我就看不到suffixprefix

Scaffold(
  body: SafeArea(
    child: Form(
      child: Padding(
        padding: const EdgeInsets.only(left: 8, right: 8),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            TextField(
              decoration: InputDecoration(
                filled: true,
                fillColor: Colors.yellow,
                prefix: Icon(Icons.add),
              ),
            ),
          ],
        ),
      ),
    ),
  ),
)

enter image description here

enter image description here

【问题讨论】:

  • 你能不能请edit把标题和问题本身都写成英文。

标签: flutter textfield


【解决方案1】:

首先,将您的问题标题更正为英文。请记住,这是一个社区,所以这个问题应该对每个人都有用。

您想要使用 prefixIcon: Icon(Icons.add) 属性而不是 prefix。 :)

【讨论】:

  • 谢谢,我混淆了 prefix 和 prefixIcon。我无法区分。
  • 没关系。是一个很容易被忽视的细节。连我都不知道。但我确实知道这个可扩展的小部件在可用性方面非常健壮和模块化,所以只需查看属性就会告诉我们应该如何使用它并解决问题。此外,对其进行分析可以提高我们的知识。强烈推荐!小心 :)
猜你喜欢
  • 2021-05-13
  • 2023-04-03
  • 1970-01-01
  • 2012-03-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-10-07
相关资源
最近更新 更多