import 'package:open_file/open_file.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; /// Handles all the notification related things. class Notifications { static FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); /// Specifies the exact notification behavior on android. static const AndroidNotificationDetails _androidSpecifics = AndroidNotificationDetails( 'com.davidpenkowoj.kulinar', 'Kulinar', importance: Importance.defaultImportance, priority: Priority.defaultPriority, autoCancel: true, playSound: false, showWhen: false, ); /// Is called when the notification is pressed. static Future selectNotification(String? payload) async { if (payload != null) { OpenFile.open(payload, type: "*/*"); // TODO: FIXME: Still doesnt work (sometimes) } } /// Launches the notification static Future notify(String title, String description, String payload) async { const NotificationDetails _platformChannelSpecifics = NotificationDetails(android: _androidSpecifics); await flutterLocalNotificationsPlugin.show(0, title, description, _platformChannelSpecifics, payload: payload); } }