[英]Validating form field in flutter
I have been trying to validate form in Flutter, the validation works but it destroys my design as shown here I tried to validate first name field, the first design was like the last name design but it destroyed when showing error message.我一直在尝试验证 Flutter 中的表单,验证有效,但它破坏了我的设计,如此处所示我尝试验证名字字段,第一个设计类似于姓氏设计,但在显示错误消息时被破坏。
The code for my TextFormField
s is here:我的
TextFormField
的代码在这里:
_showText('First Name'),
Container(
height: 50.0,
padding: const EdgeInsets.all(8.0),
child: TextFormField(
decoration: InputDecoration(
//labelText: 'First Name',
hintText: 'e.g Ali',
contentPadding: EdgeInsets.only(left: 10.0, top: 10.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(6.0),
),
),
validator: (value){
if(value.isNotEmpty) {
return null;
} else return 'First Name is required';
},
),
),
Someone Show me what is wrong with my design?有人告诉我我的设计有什么问题吗?
Your height
constraint in the Container
is causing problems.您在
Container
中的height
限制会导致问题。 Just remove that line and it should be fine只需删除该行,它应该没问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.