feat:增加通知库的版本

This commit is contained in:
2025-11-25 14:14:02 +08:00
parent 1a5efb1b48
commit 70f1e609dd
6 changed files with 29 additions and 22 deletions

View File

@@ -78,7 +78,7 @@ android {
dependencies { dependencies {
// 添加核心库脱糖依赖 // 添加核心库脱糖依赖
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4") coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
} }
flutter { flutter {

View File

@@ -6,6 +6,7 @@ import 'package:flisp_app/provider/flisp_provider.dart';
import 'package:flisp_app/utils/notify_utils.dart'; import 'package:flisp_app/utils/notify_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_common/flutter_common.dart'; import 'package:flutter_common/flutter_common.dart';
import 'package:flutter_common/utils/log_utils.dart';
import 'package:flutter_common/utils/sp_utils.dart'; import 'package:flutter_common/utils/sp_utils.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:hive_flutter/adapters.dart'; import 'package:hive_flutter/adapters.dart';
@@ -20,6 +21,8 @@ void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
// 初始化存储 // 初始化存储
await SPUtil.init(); await SPUtil.init();
// 初始化日志
await initLogger();
// 初始化提醒服务 // 初始化提醒服务
final notifyService = NotifyService(); final notifyService = NotifyService();

View File

@@ -17,9 +17,6 @@ class NotifyService {
late FlutterLocalNotificationsPlugin _notifications; late FlutterLocalNotificationsPlugin _notifications;
// 使用绝对时间(而不是相对时间),避免时区转换问题。
final dateInterpretation = UILocalNotificationDateInterpretation.absoluteTime;
// Android特殊模式即使设备处于省电模式也能准时触发。 // Android特殊模式即使设备处于省电模式也能准时触发。
final scheduleMode = AndroidScheduleMode.exactAllowWhileIdle; final scheduleMode = AndroidScheduleMode.exactAllowWhileIdle;
@@ -29,7 +26,6 @@ class NotifyService {
// 初始化时区 // 初始化时区
tz.initializeTimeZones(); tz.initializeTimeZones();
// String timeZoneName = await FlutterNativeTimezone.getLocalTimezone();
tz.setLocalLocation(tz.getLocation("Asia/Shanghai")); tz.setLocalLocation(tz.getLocation("Asia/Shanghai"));
// 设置Android平台的初始化配置 使用应用图标作为通知图标 // 设置Android平台的初始化配置 使用应用图标作为通知图标
@@ -66,11 +62,11 @@ class NotifyService {
TodoSortMode.priority, TodoSortMode.priority,
); );
final List<Todo> todayTodos = final List<Todo> todayTodos =
todoResult todoResult
.where( .where(
(todo) => !todo.isCompleted && isAfterToday(todo.scheduledTime), (todo) => !todo.isCompleted && isAfterToday(todo.scheduledTime),
) )
.toList(); .toList();
for (Todo todo in todayTodos) { for (Todo todo in todayTodos) {
await scheduleNotification( await scheduleNotification(
@@ -84,9 +80,9 @@ class NotifyService {
CalendarService calendarService = CalendarService(); CalendarService calendarService = CalendarService();
final List<Calendar> calendarResult = calendarService.getAllCalendars(); final List<Calendar> calendarResult = calendarService.getAllCalendars();
final List<Calendar> todayCalendars = final List<Calendar> todayCalendars =
calendarResult calendarResult
.where((item) => isAfterToday(item.scheduledTime)) .where((item) => isAfterToday(item.scheduledTime))
.toList(); .toList();
for (Calendar calendar in todayCalendars) { for (Calendar calendar in todayCalendars) {
await scheduleNotification( await scheduleNotification(
@@ -152,7 +148,6 @@ class NotifyService {
body, body,
tz.TZDateTime.from(scheduledTime, tz.local), tz.TZDateTime.from(scheduledTime, tz.local),
_details, _details,
uiLocalNotificationDateInterpretation: dateInterpretation,
androidScheduleMode: scheduleMode, androidScheduleMode: scheduleMode,
); );
} }

View File

@@ -350,26 +350,34 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_local_notifications name: flutter_local_notifications
sha256: ef41ae901e7529e52934feba19ed82827b11baa67336829564aeab3129460610 sha256: "19ffb0a8bb7407875555e5e98d7343a633bb73707bae6c6a5f37c90014077875"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "18.0.1" version: "19.5.0"
flutter_local_notifications_linux: flutter_local_notifications_linux:
dependency: transitive dependency: transitive
description: description:
name: flutter_local_notifications_linux name: flutter_local_notifications_linux
sha256: "8f685642876742c941b29c32030f6f4f6dacd0e4eaecb3efbb187d6a3812ca01" sha256: e3c277b2daab8e36ac5a6820536668d07e83851aeeb79c446e525a70710770a5
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "5.0.0" version: "6.0.0"
flutter_local_notifications_platform_interface: flutter_local_notifications_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: flutter_local_notifications_platform_interface name: flutter_local_notifications_platform_interface
sha256: "6c5b83c86bf819cdb177a9247a3722067dd8cc6313827ce7c77a4b238a26fd52" sha256: "277d25d960c15674ce78ca97f57d0bae2ee401c844b6ac80fcd972a9c99d09fe"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "8.0.0" version: "9.1.0"
flutter_local_notifications_windows:
dependency: transitive
description:
name: flutter_local_notifications_windows
sha256: "8d658f0d367c48bd420e7cf2d26655e2d1130147bca1eea917e576ca76668aaf"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.3"
flutter_localizations: flutter_localizations:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter

View File

@@ -1 +1 @@
name: flisp_app name: flisp_app

View File

@@ -7,6 +7,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST list(APPEND FLUTTER_FFI_PLUGIN_LIST
flutter_local_notifications_windows
) )
set(PLUGIN_BUNDLED_LIBRARIES) set(PLUGIN_BUNDLED_LIBRARIES)