email static method

String? email(
  1. String? value, {
  2. String message = "Enter valid email",
})

Implementation

static String? email(String? value, {String message = "Enter valid email"}) {
  if (value == null || value.isEmpty) return null;

  final regex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w]{2,4}$');
  if (!regex.hasMatch(value)) {
    return message;
  }
  return null;
}