[英]Fixed space between two TextFormField on Flutter
I'm trying to create an app for my work with login and signup form.我正在尝试使用登录和注册表单为我的工作创建一个应用程序。
The page is ok, but there is a litte problem: on each TextFormField there is a validator for check the field, but when appears the error message below the field, the other fields goes down.页面没问题,但有一个小问题:在每个 TextFormField 上都有一个用于检查字段的验证器,但是当该字段下方出现错误消息时,其他字段将关闭。
The question is: how can I fix the textfields?问题是:如何修复文本字段?
This is a gif demostration: https://ibb.co/VwNn2f0这是一个 gif 演示: https ://ibb.co/VwNn2f0
I try to use padding or other method finded here or on google, but I didn't find a solution.我尝试使用填充或在这里或在谷歌上找到的其他方法,但我没有找到解决方案。
you could wrap your TextField
with a SizedBox
and set a height for it:您可以用SizedBox
包装TextField
并为其设置高度:
SizedBox(
height: 80,
child: TextFormField(
validator: myValidator,
),
),
or you can also set a style for the error text, with a 0 height:或者您也可以为错误文本设置样式,高度为 0:
TextField(
decoration: InputDecoration(
errorStyle: TextStyle(height: 0),
),
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.