Flutter Dart-从国家代码获取本地国家名称
我有Alpha-2国家 /地区代码的列表。
List<String> countryCodes = ["DE", "CH", "AT"];
如何在Flutter/Dart中获取本地化的国家名称?
如果设备语言设置为英语,我想要此输出。
德国,瑞士,奥地利
如果设备语言设置为德语,我想要此输出。
Deutschland,Schweiz,Österreich
如果没有Flutter/Dart中的任何第三方套餐,这是否有可能?
在Java,您可以做..
Locale loc = new Locale("","DE");
loc.getDisplayCountry();
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();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 country_picker :
然后通过:
You can use country_picker :
and then get the localized country name via :
为了从一个国家代码中获取本地化的国家名称,可以使用pub.dev的国家代码包。
它易于使用。我建议。
https://pub.dev/packages/country_codes
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
如果您有任何国家代码并且想要获得相应的国家名称,请使用 country_picker 像这样的包装
If you have any country code and wants to get corresponding country name, use country_picker package like this