emoji property
String
emoji
Return Unicode character with flag or languageCode.
Search by country code first, then by languageToCountry map, if not found return languageCode
Note: flag may look different for different platforms!.
Note 2: svg images in this package is simplified to look good at small size, these emoji may not.
Implementation
String get emoji {
// Emoji for country
if (countryCode?.length == 2) {
return String.fromCharCodes([
countryCode!.codeUnitAt(0) + emojiOffset,
countryCode!.codeUnitAt(1) + emojiOffset
]);
}
// get country's code from languageToCountry
final str = languageCode.toLowerCase();
if (languageToCountry.containsKey(str)) {
final value = languageToCountry[str];
if (value != null && value.length > 1) {
final cc = (value[0] as String).toUpperCase().codeUnits;
// todo: check range!
return String.fromCharCodes([cc[0] + emojiOffset, cc[1] + emojiOffset]);
}
}
return countryCode ?? languageCode;
}