Issue
I have my Iphone set to English (UK) and I am trying to get the UK part in my flutter ap by doing this.
final languageCode = Platform.localeName.split('_')[0]; //prints en
final countryCode = Platform.localeName.split('_')[1]; //prints NL where I want UK
But my country code is alway NL which is my region. How can I get UK?
Solution
Its look like you want to access ISO Country Code
You can acces your device language country code with :
//Your device's all locales
final List<Locale> systemLocales = WidgetsBinding.instance!.window.locales;
//Your device's first(current) locale country code.
String? isoCountryCode = systemLocales.first.countryCode;
Answered By – guccisekspir
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0