'Tried to get location before initializing timezone database

I am trying to schedule a notification:but I got this error:

Unhandled Exception: Tried to get location before initializing timezone database

Although I initialized the Timezone in the init function:

  tz.initializeTimeZones();

schedule code:

  Future<void> scheduleNotifications(String title,int yy,int mm,int dd,int hh,int ii) async {
 
    final   loc_egypt = tz.getLocation('Africa/Cairo');       
    final tz.TZDateTime now = tz.TZDateTime.now(loc_egypt);
    var schedule_30before=tz.TZDateTime(loc_egypt,yy,mm,dd,hh,ii).subtract(Duration(minutes: 30));


      await flutterLocalNotificationsPlugin.zonedSchedule(
          0,
          title,
          "The Webinar will start after 30 minutes",
          schedule_30before,
          NotificationDetails(android: _androidNotificationDetails),
          androidAllowWhileIdle: true,
          uiLocalNotificationDateInterpretation:
          UILocalNotificationDateInterpretation.absoluteTime);


  }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source