1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// 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<dynamic> selectNotification(String? payload) async {
if (payload != null) {
// OpenFile.open(payload, type: "*/*");
}
}
/// Launches the notification
static Future<void> notify(String title, String description, String payload) async {
const NotificationDetails platformChannelSpecifics = NotificationDetails(android: _androidSpecifics);
await flutterLocalNotificationsPlugin.show(0, title, description, platformChannelSpecifics, payload: payload);
}
}
|