[英]Flutter TextFormField Validation Error Text Padding
I have a TextFormField.我有一个 TextFormField。 This widget validation is empty show error text.
此小部件验证为空,显示错误文本。 However, the error text fill looks like the picture.
但是,错误文本填充看起来像图片。 How can i solve it.
我该如何解决。
SizedBox(
height: 50,
child: TextFormField(
validator: (val) {
if (val!.isEmpty) {
return "Boş Geçilemez";
}
if (val.length > 100) {
return "Karakter Sınırı Hatası";
}
return null;
},
obscureText: true,
decoration: InputDecoration(
suffixIcon: const Icon(
Icons.lock_outline_rounded,
color: Color(0xffBDBDBD),
),
hintText: AppLocalizations.getString("sifre"),
contentPadding:
const EdgeInsets.only(top: 14, left: 10, bottom: 10)),
controller: passwordController,
),
),
It would be better if you use same content padding for top and bottom, and try increasing the height of TextFiled like 64.如果您对顶部和底部使用相同的内容填充,并尝试将 TextFiled 的高度增加到 64 会更好。
And use autovalidateMode: AutovalidateMode.onUserInteraction,
并使用
autovalidateMode: AutovalidateMode.onUserInteraction,
SizedBox(
height: 64,
child: TextFormField(
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (val) {
if (val != null && val.isEmpty) {
return "Boş Geçilemez";
}
if (val!.length > 10) {
return "Karakter Sınırı Hatası";
}
return null;
},
decoration: InputDecoration(
suffixIcon: const Icon(
Icons.lock_outline_rounded,
color: Color(0xffBDBDBD),
),
hintText: "sifre",
contentPadding: const EdgeInsets.only(
top: 14,
left: 10,
bottom: 14,
)),
),
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.