| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import 'package:flutter/foundation.dart';
- import 'package:local_notifier/local_notifier.dart';
- const _appName = "AppFlowy";
- /// Manages Local Notifications
- ///
- /// Currently supports:
- /// - MacOS
- /// - Windows
- /// - Linux
- ///
- class NotificationService {
- static Future<void> initialize() async {
- await localNotifier.setup(
- appName: _appName,
- shortcutPolicy: ShortcutPolicy.requireCreate, // Windows Specific
- );
- }
- }
- /// Creates and shows a Notification
- ///
- class NotificationMessage {
- NotificationMessage({
- required String title,
- required String body,
- String? identifier,
- VoidCallback? onClick,
- }) {
- _notification = LocalNotification(
- identifier: identifier,
- title: title,
- body: body,
- )..onClick = onClick;
- _show();
- }
- late final LocalNotification _notification;
- void _show() => _notification.show();
- }
|