defaultEmailValidattor static method

(String? Function(String?)?) defaultEmailValidattor(
  1. String? errorText
)

Implementation

static String? Function(String?)? defaultEmailValidattor(String? errorText) => (value) {
      String pattern = r'.+@.+\..+'; //Has at least one character before the @, before the period and after it
      RegExp regex = RegExp(pattern);
      if (!regex.hasMatch(value!)) {
        return errorText ?? 'Invalid email';
      } else {
        return null;
      }
    };