LocationNotFoundException (Location with the name "GMT" doesn't exist)

994

Are you working on an emulator ? By default, there is no timezone set. So you have to choose one so the GMT will not be null.

Have you tried to change the timezone in phone's settings ?

I was working on emulator and changing timezone from United States to France stopped crashing my app

Share:
994
Admin
Author by

Admin

Updated on December 06, 2022

Comments

  • Admin
    Admin over 1 year

    i need to create local notification for scheduling, the issue is when i use setLocalLocation function to get the time zone name which equals [log] timeZoneName value is =>GMT .

    the exception is:

    LocationNotFoundException (Location with the name "GMT" doesn't exist)
    

    the main function:

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

    _configureLocalTimeZone function:

    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));
    }