diff --git a/ui/flutter/lib/app/application/app_notification_controller.dart b/ui/flutter/lib/app/application/app_notification_controller.dart index 4ce0adc1..bd09d189 100644 --- a/ui/flutter/lib/app/application/app_notification_controller.dart +++ b/ui/flutter/lib/app/application/app_notification_controller.dart @@ -2,10 +2,9 @@ import 'dart:async'; import 'dart:io'; import 'package:flutter/foundation.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:path_provider/path_provider.dart'; +import 'package:path/path.dart' as path; import '../../core/common/task_event.dart'; import '../../core/libgopeed_boot.dart'; @@ -57,18 +56,23 @@ class AppNotificationController extends AsyncNotifier { String? windowsIconPath; try { if (Util.isWindows()) { - // Windows reads the toast header icon through the registered IconUri. - // Use a PNG in persistent storage so notification history can still - // resolve it after the app exits or temporary files are cleaned up. - final byteData = await rootBundle.load('assets/icon/icon_512.png'); - final supportDir = await getApplicationSupportDirectory(); - final file = File('${supportDir.path}/notification_icon.png'); - await file.parent.create(recursive: true); - await file.writeAsBytes( - byteData.buffer.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes), - flush: true, + // Windows requires a file path for IconUri, so use the bundled PNG + // beside the executable rather than copying it to another directory. + final file = File( + path.join( + path.dirname(Platform.resolvedExecutable), + 'data', + 'flutter_assets', + 'assets', + 'icon', + 'icon_512.png', + ), ); - windowsIconPath = file.absolute.path; + if (await file.exists()) { + windowsIconPath = file.absolute.path; + } else { + logger.w('Windows notification icon not found: ${file.path}'); + } } } catch (error, stackTrace) { logger.w('prepare Windows notification icon failed', error, stackTrace);