class EmailITextField extends StatelessWidget {
final String hintText;
final IconData icon;
final ValueChanged<String> onChanged;
final TextEditingController controller;
final Validator validator; //here
const EmailITextField({
Key key,
this.hintText,
this.icon = Icons.person,
this.onChanged,
this.validator,
this.controller
}) : super(key: key);
@override
Widget build(BuildContext context) {
return TextFieldContainer(
child: TextFormField(
validator: validator,
controller: controller,
onChanged: onChanged,
cursorColor: kPrimaryightColor,
decoration: InputDecoration(
icon: Icon(
icon,
color: kPrimaryColor,
),
labelText: hintText,
labelStyle: TextStyle(color: kPrimaryColor) ,
hintText: "[email protected]",
border: InputBorder.none,
),
),
);
}
}
There is no Validator thing, i want to add Validator attribute on this reusable widget, but i dont know how to add the Validator attribute.
any other name?
question from:
https://stackoverflow.com/questions/65642431/is-there-any-validator-in-textformfield-in-flutter 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…