isValid method

bool isValid({
  1. bool allowTopLevelDomains = false,
  2. bool allowInternational = true,
})

Returns true when address is a valid complete email address.

If allowTopLevelDomains is true, addresses like user@example are allowed.

If allowInternational is true, international characters are allowed.

IMPORTANT: Validating email addresses is tricky, because email providers usually don't completely agree on the rules. This method uses rules that are most commonly accepted, but the only way to be 100% sure you are not discarding an email address that could be delivered is to use a much more permissive validation and then try to send the email and see if it bounces.

Implementation

bool isValid({bool allowTopLevelDomains = false, bool allowInternational = true}) {
  return _EmailValidator(address).validate(
    allowTopLevelDomains: allowTopLevelDomains,
    allowInternational: allowInternational,
  );
}