Flutter Dart - get localized country name from country code

823

To get the localized country names from a country code one can use the Country Codes package from pub.dev.

Its easy to use. I recommend.

https://pub.dev/packages/country_codes

Share:
823
Nao Kreuzeder
Author by

Nao Kreuzeder

Updated on January 05, 2023

Comments

  • Nao Kreuzeder
    Nao Kreuzeder over 1 year

    I have a list of alpha-2 country codes.

     List<String> countryCodes = ["DE", "CH", "AT"];
    

    How to get the localized country names in Flutter/Dart?

    If the device language is set to english, i want this output..

    Germany, Switzerland, Austria

    If the device language is set to german, i want this output..

    Deutschland, Schweiz, Österreich

    Is this possible without any 3rd party package in Flutter/Dart?

    In Java you could do..

    Locale loc = new Locale("","DE");
    loc.getDisplayCountry();
    
    • Tirth Patel
      Tirth Patel almost 2 years
    • Nao Kreuzeder
      Nao Kreuzeder almost 2 years
      No, this is not what i was looking for. I need the "Country Name" from the Country Code (eg. 'DE', 'RU', 'US', 'HU' etc.), not the "Language Code".
    • Randal Schwartz
      Randal Schwartz almost 2 years
      There is nothing in the Dart or Flutter SDK that will do that, so I imagine your answer to "Is this possible" is simply... NO. But if you still need it done, perhaps something in "pub" will suffice.