简体   繁体   English

Textformfield 输入文本 position 不等于图标 flutter

[英]Textformfield input text position not equal with icon flutter

i have textformfield that have icon, but the input text position not equal with the icon i have somehow我有带有图标的 textformfield,但输入文本 position 不等于我有某种图标

how do i fix this?我该如何解决?

code i tried我试过的代码

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对此

Please follow below approach:请遵循以下方法:

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

Please use content padding inside InputDecoration and also try to put TextFormField inside container for better alignment.请在 InputDecoration 中使用内容填充,并尝试将 TextFormField 放入容器中以获得更好的 alignment。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM