sanitize method
Returns address with unsupported characters removed. Use this while the user is typing an email address.
This is not a validator. The returned value can still be incomplete or
invalid. For example, it can return user@.
If allowInternational is true, non ASCII characters are kept.
See: EmailTextInputFormatter, which uses this to sanitize the input.
Implementation
String sanitize({bool allowInternational = true}) {
return address
.split('')
.where(
(char) => _isAllowedPartialChar(char, allowInternational: allowInternational),
)
.join();
}