2

I am trying to implement local notification which works perfect before I upgrade my app version as below:

FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;

  showNotification() async {
   var android = AndroidNotificationDetails(
        'channel id', 'channel name');
    var iOS = DarwinNotificationDetails();
    var platform = NotificationDetails(android: android, iOS: iOS);
    await flutterLocalNotificationsPlugin.periodicallyShow(0, 'Hello user,',
        "Don't miss out on the exciting deals for the day.", RepeatInterval.everyMinute, platform);
   
  }

But since I changed to flutter_local_notifications: ^10.0.0 then I couldn't get any notification again.Though I got an error message [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: NoSuchMethodError: The method 'periodicallyShow' was called on null. and Tried calling: periodicallyShow(0, "Hello Hobber,", "Don't miss out on the exciting deals for the day.", Instance of 'RepeatInterval', Instance of 'NotificationDetails') Can someone help?

  • Well it seems that `FlutterLocalNotificationsPlugin` is not created so you are calling method `periodicallyShow()` on null value. You should read the changelog [here](https://pub.dev/packages/flutter_local_notifications/changelog) for the appropriate version. If your error is really caused by the upgrade of this plugin, you might find what breaking changes they introduced. – Karolis Nov 07 '22 at 13:12
  • I have it declared already but still the same error. – YourDeveloper Nov 07 '22 at 17:52

1 Answers1

0

Initialize FlutterLocalNotificationsPlugin object like this:

FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin()

Humza Ali
  • 86
  • 4