encodedAddress property
String
get
encodedAddress
Returns the mail address with the domain encoded using IDNA (Punycode).
This properly handles internationalized domain names by:
- Normalizing Unicode to NFC
- Converting the domain to Punycode using
emailToAscii
The local-part (before @) is not modified by emailToAscii.
Implementation
String get encodedAddress {
try {
if (!mailAddress.contains('@')) {
return mailAddress;
}
// Normalize to NFC before encoding
final normalized = unorm.nfc(mailAddress);
return emailToAscii(normalized);
} catch (_) {
return mailAddress;
}
}