isEmail property

bool get isEmail

Checks if the string is a valid email address.

This method uses a regular expression to validate the format of an email address. It checks that the string contains characters, an '@' symbol, a domain name, and a top-level domain.

Example:

var email = 'example@example.com';
print(email.isEmail); // Outputs: true

Returns true if the string is a valid email address, otherwise false.

Implementation

bool get isEmail {
  const regex =
      r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+";
  return RegExp(regex).hasMatch(this);
}