isEmail property
bool
get
isEmail
Returns true if this string is a valid email address format.
Uses a simple regular expression to validate the pattern:
- local part (alphanumeric, dot, or hyphen)
- '@' symbol
- domain part (alphanumeric, dot, or hyphen)
- ends with a valid top-level domain (2+ characters)
Implementation
bool get isEmail {
final emailRegex = RegExp(r'^[\w\.-]+@[\w\.-]+\.\w{2,}$');
return emailRegex.hasMatch(this);
}