email method
FormFieldValidator
that requires the field's value to be a valid url.
Implementation
static FormFieldValidator email({
String errorText = "This field requires a valid email address.",
}) {
return (val) {
if (val != null && val.isNotEmpty) {
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,}))$';
if (!RegExp(pattern).hasMatch(val)) return errorText;
}
};
}