localNotificationPluginProvider top-level property

FutureProvider<FlutterLocalNotificationsPlugin> localNotificationPluginProvider
final

Provides the Flutter local notifications plugin for displaying notifications

Implementation

final localNotificationPluginProvider =
    FutureProvider<FlutterLocalNotificationsPlugin>((ref) async {
  final plugin = FlutterLocalNotificationsPlugin();
  const settings = InitializationSettings(
    android: AndroidInitializationSettings('ic_notification'),
    iOS: DarwinInitializationSettings(),
  );

  await plugin.initialize(
    settings,
    onDidReceiveNotificationResponse: (response) async {
      // May be receieved in a background thread. Create a new db connection
      final container = ProviderContainer(overrides: realDatabaseOverrides);
      final database = container.read(sharedDatabaseProvider);
      await addActionToDatabase(database, response);
      container.dispose();
    },
  );

  return plugin;
});