LocationNotFoundException(名称为“GMT”的位置不存在)

5 push-notification dart flutter

我需要创建本地通知以进行调度,问题是当我使用 setLocalLocation 函数获取等于 的时区名称时[log] timeZoneName value is =>GMT

例外是:

LocationNotFoundException (Location with the name "GMT" doesn't exist)
Run Code Online (Sandbox Code Playgroud)

主要功能:

const MethodChannel platform = MethodChannel('dexterx.dev/example_app');
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await _configureLocalTimeZone();
runApp(MyApp());
}
Run Code Online (Sandbox Code Playgroud)

_configureLocalTimeZone函数:

Future<void> _configureLocalTimeZone() async {
  tz.initializeTimeZones();
  final String timeZoneName = await platform.invokeMethod('getTimeZoneName');
  log("timeZoneName value is =>$timeZoneName",error: {"name":"Value or not"});
  tz.setLocalLocation(tz.getLocation(timeZoneName));
}
Run Code Online (Sandbox Code Playgroud)

Pie*_*ckG 7

您正在开发模拟器吗?默认情况下,没有设置时区。所以你必须选择一个,这样 GMT 就不会为空。

您是否尝试过更改手机设置中的时区?

我正在开发模拟器,将时区从美国更改为法国不再使我的应用程序崩溃