validate method
A function that returns an error message string
to display if the input s
not pass a validation
test and returns null otherwise.
Implementation
@override
String? validate(String email) {
const pattern =
r"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?)*$";
bool r = RegExp(pattern).hasMatch(email);
return r ? null : "Please enter a valid email address.";
}