Home > database >  Flutter local notification not work in latest version
Flutter local notification not work in latest version

Time:11-08

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?

CodePudding user response:

Initialize FlutterLocalNotificationsPlugin object like this:

FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin()

  • Related