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 {
// 添加核心库脱糖依赖
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
}
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:flutter/material.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_localizations/flutter_localizations.dart';
import 'package:hive_flutter/adapters.dart';
@@ -20,6 +21,8 @@ void main() async {
WidgetsFlutterBinding.ensureInitialized();
// 初始化存储
await SPUtil.init();
// 初始化日志
await initLogger();
// 初始化提醒服务
final notifyService = NotifyService();

View File

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

View File

@@ -350,26 +350,34 @@ packages:
dependency: "direct main"
description:
name: flutter_local_notifications
sha256: ef41ae901e7529e52934feba19ed82827b11baa67336829564aeab3129460610
sha256: "19ffb0a8bb7407875555e5e98d7343a633bb73707bae6c6a5f37c90014077875"
url: "https://pub.flutter-io.cn"
source: hosted
version: "18.0.1"
version: "19.5.0"
flutter_local_notifications_linux:
dependency: transitive
description:
name: flutter_local_notifications_linux
sha256: "8f685642876742c941b29c32030f6f4f6dacd0e4eaecb3efbb187d6a3812ca01"
sha256: e3c277b2daab8e36ac5a6820536668d07e83851aeeb79c446e525a70710770a5
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.0.0"
version: "6.0.0"
flutter_local_notifications_platform_interface:
dependency: transitive
description:
name: flutter_local_notifications_platform_interface
sha256: "6c5b83c86bf819cdb177a9247a3722067dd8cc6313827ce7c77a4b238a26fd52"
sha256: "277d25d960c15674ce78ca97f57d0bae2ee401c844b6ac80fcd972a9c99d09fe"
url: "https://pub.flutter-io.cn"
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:
dependency: "direct main"
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
flutter_local_notifications_windows
)
set(PLUGIN_BUNDLED_LIBRARIES)