emailValidator function

String? emailValidator(
  1. String value
)

Validates whether the input value is a valid email address.

Implementation

String? emailValidator(String value) {
  final emailRegExp = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
  return !emailRegExp.hasMatch(value.trim())
      ? 'Please enter a valid email address.'
      : null;
}