validateEmail static method

String? validateEmail(
  1. String? email
)

Email address validation helper method

Implementation

static String? validateEmail(String? email) {
  var 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,}))$';
  RegExp regex = RegExp(pattern);
  if (email != null && !regex.hasMatch(email)) {
    return 'Enter Valid Email';
  } else {
    return null;
  }
}