如何通过颤振中的设备位置获取时区、语言和县 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. Is there any library or I can get these via the internal library, please suggest another way.
推荐答案
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-core/DateTime-class.html
这篇关于如何通过颤振中的设备位置获取时区、语言和县 Id?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!