如何通过颤动中的设备位置获取颤动中的时区、语言和县 ID? [英] How to get timezone, Language and County Id in flutter by the location of device in flutter?
问题描述
我是 Flutter 的新手,我想在我的设备 android 或 iOS 上运行我的项目时获取时区、语言和县 ID.它应该从设备的位置检测时区、语言和国家 ID.我是新手,不知道如何获得这些.
I am new to flutter, and I want to get Timezone, language, and county Id when I run my project on my device android or iOS. It should detect Timezone, language and country Id from the location of the device. I am newbie to flutter and don't know how can I get these.
我可以通过内部库获得这些吗?
Can I get these via the internal library?
推荐答案
https://flutter.io/tutorials/internationalization/#tracking-locale
Locale myLocale = Localizations.localeOf(context);
Locale myLocale = Localizations.localeOf(context);
提供countryCode
和languageCode
https://docs.flutter.io/flutter/dart-ui/Locale-class.html
时区应该可用(未尝试)
The timezone should be available with (not tried)
DateTime.now().timeZoneName
https://docs.flutter.io/flutter/dart-核心/DateTime-class.html
这篇关于如何通过颤动中的设备位置获取颤动中的时区、语言和县 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!