【发布时间】:2020-10-02 15:05:05
【问题描述】:
我有一个博客应用程序,我可以在其中编写面向全球的商业内容以及一些特定于国家/地区的内容。喜欢印度、印度尼西亚等的特别帖子。
这就是为什么我需要一种方法来查找用户要从哪个国家/地区提供特定内容。
但是,我不想使用 GeoLocator 插件,因为它会询问 位置的用户。我只想要用户的国家,而不是具体的 位置,但权限对话框没有指定可以使 用户担心为什么这个应用程序需要位置权限。那是 为什么我想要一种无需隐式许可即可获取用户国家/地区的方法 对话框询问他们的位置。
我尝试了以下方法,但没有一个给出确切的国家名称。
import 'dart:io' show Platform;
String localeName = Platform.localeName;
// this returns language device is using which mostly comes us en_US so this is of no use
Locale myLocale = Localizations.localeOf(context);
// This returned the US as the country despite the App being opened and used in India.
【问题讨论】:
标签: android flutter geolocation flutter-dependencies google-location-services