[英]TextFormField showing error inside the TextFormField- Flutter
As shown in image, error message disturb TextField.如图所示,错误消息会干扰 TextField。 I am using container a parent widget to make some UI stuff but this happened.
我正在使用容器作为父小部件来制作一些 UI 内容,但发生了这种情况。 Without validation message it works fin I want error message below the TextField not inside, kindly help.
如果没有验证消息,它就可以工作,我希望 TextField 下方的错误消息不在里面,请帮忙。
As shown in image, error message disturb TextField.如图所示,错误消息会干扰 TextField。 I am using container a parent widget to make some UI stuff but this happened.
我正在使用容器作为父小部件来制作一些 UI 内容,但发生了这种情况。 Without validation message it works fine.
没有验证消息它工作正常。 I want error message below the TextField not inside, kindly help.
我想要 TextField 下面的错误消息不在里面,请帮忙。
import 'package:flutter/material.dart';
import 'package:email_validator/email_validator.dart';
class RoundedTextField extends StatelessWidget {
final String hintText;
final IconData iconData;
final Color hintcolor, iconcolor;
final bool password;
final TextEditingController tcontroller;
final TextInputType tType;
const RoundedTextField(
{Key key,
@required this.hintText,
@required this.iconData,
@required this.hintcolor,
this.iconcolor,
this.password,
this.tcontroller,
this.tType})
: super(key: key);
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Container(
margin: EdgeInsets.symmetric(vertical: 10),
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 20),
width: size.width * 0.8,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(29),
color: Color(0xFFa5b2fc),
),
child: TextFormField(
controller: tcontroller,
obscureText: password,
keyboardType: tType,
validator: (String value) {
bool isValid = EmailValidator.validate(value);
if (!password) {
if (!isValid) {
return "Invalid Email Address";
}
}
},
decoration: InputDecoration(
suffixIcon: password
? (Icon(
Icons.visibility,
color: iconcolor,
))
: null,
border: InputBorder.none,
icon: Icon(
iconData,
color: iconcolor,
),
hintText: hintText,
hintStyle: TextStyle(color: hintcolor),
),
),
);
}
}
Use the decoration within the TexformField.使用 TexformField 中的装饰。 Including Text, borders, Shapes, Colors
包括文本、边框、形状、颜色
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.