validateEmail static method
Validates an email address. Returns null if valid, otherwise an error message.
Implementation
static String? validateEmail(String? value) {
if (value == null || value.isEmpty) return 'Email is required';
final emailRegex = RegExp(r'^[\w\-.]+@([\w-]+\.)+[\w-]{2,4}$');
if (!emailRegex.hasMatch(value)) return 'Enter a valid email';
return null;
}