Flutter 验证程序消息正在接触用户输入文本
我试图制作一个定制的文本框,但在验证消息和输入文本框方面有困难。文本框输入文本与验证错误消息重叠 下面是我的代码Flutter 验证程序消息正在接触用户输入文本,flutter,dart,flutter-layout,Flutter,Dart,Flutter Layout,我试图制作一个定制的文本框,但在验证消息和输入文本框方面有困难。文本框输入文本与验证错误消息重叠 下面是我的代码 Padding( padding: const EdgeInsets.only( left: 25.0, right: 25.0, top: 15.0), child: Container( height: 53.5, dec
Padding(
padding: const EdgeInsets.only(
left: 25.0, right: 25.0, top: 15.0),
child: Container(
height: 53.5,
decoration: BoxDecoration(
color: Color(0xFF23252E),
borderRadius: BorderRadius.all(Radius.circular(5.0)),
border: Border.all(
color: Colors.black12,
width: 0.15,
),
),
child: Padding(
padding: const EdgeInsets.only(
left: 12.0, right: 12.0, top: 5.0),
child: Theme(
data: ThemeData(hintColor: Colors.transparent),
child: Padding(
padding: const EdgeInsets.only(left: 10.0),
child: TextFormField(
controller: emailController,
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: validateEmail,
style: new TextStyle(color: Colors.white),
textAlign: TextAlign.start,
keyboardType: TextInputType.emailAddress,
autocorrect: false,
autofocus: false,
decoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.all(0.0),
filled: true,
fillColor: Colors.transparent,
labelText: 'Email',
hintStyle: TextStyle(color: Colors.white),
labelStyle: TextStyle(
color: Colors.white70,
)),
),
),
),
),
),
),
这是我的验证器
String validateEmail(String value) {
Pattern pattern =
r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
RegExp regex = new RegExp(pattern);
if (!regex.hasMatch(value))
return 'Enter Valid Email';
else
return null;
}
String validateEmail(字符串值){
图案=
r'^([^()[\]\\,;:\s@']+(\.[^()[\]\,;:\s@']+*))(\[[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[1,3}.[0-9]{1,3}.]124;([a-zA Z-0-9]{a-zA Z]++$){2};
RegExp regex=新的RegExp(模式);
如果(!regex.hasMatch(值))
返回“输入有效电子邮件”;
其他的
返回null;
}
我相信这与填充有关,只是不确定我哪里出了问题