You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
void getEnglishCountryName(String countryCode) async {
final localizations = CountryLocalizations(Locale('en'));
await localizations.load();
String? countryName = localizations.translate(countryCode);
print(countryName); // This should print "Sweden" for "SE"
}
// Using the function
getEnglishCountryName('SE');
But getEnglishCountryName('US') prints "[United States of America, USA]" instead of a single human-readable name, perhaps due to toString() being used here:
@amin79 while waiting for a reaction from the maintainer(s), I'm using this patch, which goes for the first value in the list and ignores the others tomsun@a2ceef5
(Note that my fork is a bit behind @chandrabezzo 's repo - I'm using the final snapshot from @imtoori + an upgrade of modal_bottom_sheet + this fix. But the patch probably fits onto @chandrabezzo 's version aswell)
This works as expected
But
getEnglishCountryName('US')
prints"[United States of America, USA]"
instead of a single human-readable name, perhaps due to toString() being used here:CountryCodePicker/lib/src/country_localizations.dart
Line 29 in 6ee7de3
The text was updated successfully, but these errors were encountered: