srawlins / timezone

Time zone database and time zone aware DateTime object for Dart.
BSD 2-Clause "Simplified" License
102 stars 54 forks source link

Unhandled Exception: NoSuchMethodError: The method 'timeZone' was called on null. #91

Closed drexhacker closed 1 year ago

armandojimenez commented 3 years ago

getting the same

talwarabhimanyu commented 3 years ago

I'm getting the same error. Here is how I am using the package. Kindly help.

import 'package:timezone/data/latest.dart' as tz;
import 'package:timezone/timezone.dart' as tz;

void main async {
  tz.initializeTimeZones();
  tz.setLocalLocation(tz.getLocation(await FlutterNativeTimezone.getLocalTimezone()));
  runApp(App());
}

Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
  var notifyTime = tz.TZDateTime.now(tz.local).add(Duration(seconds: 10));
}
srawlins commented 2 years ago

Apologies for the late reply. In addition to the repro code, can someone provide a stack trace? The repro code in the last comment does not call timeZone.

srawlins commented 1 year ago

Closing; please open a new issue with details if it occurs again.