I'm trying to use zonedshedule in Flutter local notifications. But exception is returning as null 'timeZone' was called on null.
            Asked
            
        
        
            Active
            
        
            Viewed 939 times
        
    1 Answers
6
            Import packages from timezone package from pub dev
Now, add those to your dart file as referring to tz:
import 'package:timezone/timezone.dart' as tz;
import 'package:timezone/data/latest.dart' as tz;
Now, make initialize the timeZones:
void main() {
  tz.initializeTimeZones();
  var locations = tz.timeZoneDatabase.locations;
}
Now, you can convert DateTime to TZDateTime for zonedShedule:
DateTime time;
tz.TZDateTime selectedDate;
selectedDate =  tz.TZDateTime.from(time, tz.local);
 
    
    
        Rahul Kavati
        
- 3,800
- 3
- 7
- 15