email static method

ValidationRule email([
  1. String message = 'Enter a valid email address'
])

Implementation

static ValidationRule email([String message = 'Enter a valid email address']) {
  return ValidationRule((value) {
    if (value == null || value.isEmpty) return null;
    final regex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
    return regex.hasMatch(value) ? null : message;
  });
}