'how to push local notification even the app is killed so it work in the background?

in the main i'm checking if a data in shared preferences is true the launch a local notification it work fine if the app is running but if it killed, never work i need a something like reminder so it work in the background work when a certain time comes , it push notification i tried to use flutter_isolate with Flutter_startup but didn't work this is the code i used

import 'package:flutter_isolate/flutter_isolate.dart';
import 'package:flutter_startup/flutter_startup.dart';
//this code in the package of flutter_isolate and do't understand it
void isolate2(String arg) async {
  FlutterStartup.startupReason.then((reason) {
  });
 }
 //also this but the timer is mine
 void isolate1(String arg) async {
 final isolate = await FlutterIsolate.spawn(isolate2, "hello2");
 SharedPreferences preferences = await SharedPreferences.getInstance();
 FlutterStartup.startupReason.then((reason) {
 });
 Timer.periodic(Duration(seconds: 10), (timer) {
   log(">>>> inside timer");
   if (preferences.getString("randomtime") != null) {
    if (preferences.getString("randomtime") == "true") {
      NotificationApi.showNotification(
      body: "this is body",
      id: 3,
      payload: "this is payload",
      title: "this is title",
      );
     }
   }
 });
 }

 void main() async {
 WidgetsFlutterBinding.ensureInitialized();
 await GetStorage.init();
 SharedPreferences preferences = await SharedPreferences.getInstance();
 final isolate = await FlutterIsolate.spawn(isolate1, "hello");
 Timer.periodic(Duration(seconds: 10), (timer) => isolate.resume());


 runApp(MyApp());
 }

this package didn't help me to run the app in the background



Solution 1:[1]

You may wanna try to use one of the following packages for local Push Notifications:

Solution 2:[2]

i solved it when add NotificationApi.init(); before timer periodic

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 LucianoJ
Solution 2 Michael Nabil