flutter - Textformfield输入文本位置不等于图标颤动
问题描述
我有带有图标的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
),
),
],
)
);
}
}
解决方案
请遵循以下方法:
contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
请在 InputDecoration 中使用内容填充,并尝试将 TextFormField 放入容器中以更好地对齐。
推荐阅读
- amazon-web-services - 将 EFS 挂载到 EC2 上,然后挂载到 docker 容器上
- asp.net - 在 iis express 中托管 asp.net core 项目需要 asp.net core 模块,但似乎没有安装。尝试修复 Visual Studio 2019
- websocket - GraphQL 订阅和 WebSocket 协议有什么区别?
- python - 链表中的有序插入不添加节点
- ruby-on-rails - 通过关系在 has_many 中具有嵌套属性的 Rails 表单
- fortran - 无法使用通常的自等效来识别 nvfortran 中的 nan
- snowflake-cloud-data-platform - 雪花中的 LISTAGG Func 性能
- javascript - skydark API 返回 CORS 问题
- laravel - 未为自定义包加载服务器提供程序
- c - 使用暗网生成 ROC 曲线?我需要选择一个模型来最小化特定类的假阴性数量