【问题标题】:Textformfield input text position not equal with icon flutterTextformfield输入文本位置不等于图标颤动
【发布时间】:2019-11-18 03:12:27
【问题描述】:

我有带有图标的 textformfield,但输入文本的位置与我的图标不相等

我该如何解决这个问题?

我试过的代码

class TestPage extends StatefulWidget {
  @override
  _TestPageState createState() => _TestPageState();
}

class _TestPageState extends State<TestPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          TextFormField(
            decoration: InputDecoration(
                prefixIcon: Icon(Icons.person),
                filled: true,
                hintText: 'Email',
                fillColor: Colors.white
            ),
          ),
          TextFormField(
            decoration: InputDecoration(
                prefixIcon: Icon(Icons.https),
                filled: true,
                hintText: 'Password',
                fillColor: Colors.white
            ),
          ),
        ],
      )
    );
  }
}

from

to this

【问题讨论】:

  • 嗨,Karin,你能展示一下你到目前为止所做的相关代码吗?
  • 你好迈克尔,我为代码编辑了我的问题

标签: flutter flutter-layout


【解决方案1】:

请遵循以下方法:

contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),

请在 InputDecoration 中使用内容填充,并尝试将 TextFormField 放入容器中以更好地对齐。

【讨论】:

  • 谢谢你,不是我所期望的,但它可以给我想要的
  • 谢谢!它排序:dart:ui/text.dart':断言失败:第 1372 行:'':不是 true 错误。
猜你喜欢
  • 2021-08-17
  • 2021-06-28
  • 1970-01-01
  • 1970-01-01
  • 2019-11-16
  • 2021-09-09
  • 2020-10-11
  • 2020-07-15
  • 1970-01-01
相关资源
最近更新 更多