feat:初始化工程
This commit is contained in:
31
lib/notice.dart
Normal file
31
lib/notice.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
|
||||
// 初始化通知
|
||||
Future<void> _initNotify() async {
|
||||
final notify = FlutterLocalNotificationsPlugin();
|
||||
await notify.initialize(
|
||||
const InitializationSettings(
|
||||
windows: WindowsInitializationSettings(
|
||||
appName: 'TaskHub',
|
||||
appUserModelId: 'com.cxx.task',
|
||||
guid: 'f47ac10b-58cc-4372-a567-0e02b2c3d479',
|
||||
iconPath: 'assets/icons/task.png'
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 发送通知
|
||||
Future<void> _showNotify(String title, String text) async {
|
||||
final notify = FlutterLocalNotificationsPlugin();
|
||||
final id = DateTime.now().millisecondsSinceEpoch.remainder(10000);
|
||||
|
||||
await notify.show(
|
||||
id,
|
||||
title,
|
||||
text,
|
||||
const NotificationDetails(
|
||||
windows: WindowsNotificationDetails(),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user