tjarvstrand / flutter_timezone

A fork of https://github.com/pinkfish/flutter_native_timezone
Apache License 2.0
42 stars 29 forks source link

[QUESTION] Crash on invalid location name #20

Closed under3415 closed 7 months ago

under3415 commented 9 months ago

Getting below error on code stolen from the example. Cannot replicate it, it is happening on one user's Android TV device. Why would this happen? Something weird with that device? Also, I can handle the error, but what to do?

    tz.initializeTimeZones();
    final String timeZoneName = await FlutterTimezone.getLocalTimezone();
    tz.setLocalLocation(tz.getLocation(timeZoneName));

Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Location with the name "GMT-06:00" doesn't exist

00 pc 0x42898f com.example.app (LocationDatabase.get [location_database.dart:40]) (BuildId: 3aa6f915793da4081e48b7113565b3a6)

01 pc 0x428893 com.example.app (getLocation [env.dart:36]) (BuildId: 3aa6f915793da4081e48b7113565b3a6)

02 pc 0x863597 com.example.app (_configureLocalTimeZone [main.dart:41]) (BuildId: 3aa6f915793da4081e48b7113565b3a6)

03 pc 0x862ef3 com.example.app (main [main.dart:136]) (BuildId: 3aa6f915793da4081e48b7113565b3a6)

tjarvstrand commented 9 months ago

Basically, it looks like the device doesn't have a named time zone set, only a UTC offset.

How to solve this would depend on your use case but if you REALLY need a time zone name the best you can do is take a guess.

tjarvstrand commented 7 months ago

I'll close this. Feel free to reopen if you think there's an issue with flutter_timezone.