From b142c34f0fd8e5fe71bf1dbe927828e6a40d7ea3 Mon Sep 17 00:00:00 2001 From: Anton Schmidt <46531415+SetupCoding@users.noreply.github.com> Date: Thu, 7 May 2026 04:44:46 +0200 Subject: [PATCH] fix: Windows file save dialog appearing behind app window (#3214) Add lockParentWindow: true to all FilePicker.platform.saveFile() calls so the Win32 save dialog gets the Flutter window as its owner and appears in front of the application instead of behind it. Also handle null result (user cancellation) gracefully instead of force-unwrapping, which would throw an unhandled exception. Fixes cake-tech/cake_wallet#3107 --- lib/src/screens/backup/backup_page.dart | 9 +++++++-- lib/src/screens/seed/wallet_seed_page.dart | 1 + lib/src/screens/settings/mweb_logs_page.dart | 9 +++++++-- lib/src/screens/settings/silent_payments_logs_page.dart | 9 +++++++-- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/src/screens/backup/backup_page.dart b/lib/src/screens/backup/backup_page.dart index cab867bf5..59abff990 100644 --- a/lib/src/screens/backup/backup_page.dart +++ b/lib/src/screens/backup/backup_page.dart @@ -172,10 +172,15 @@ class BackupPage extends BasePage { Future _saveFile(BackupExportFile backup) async { String? outputFile = await FilePicker.platform - .saveFile(dialogTitle: 'Save Your File to desired location', fileName: backup.name); + .saveFile( + dialogTitle: 'Save Your File to desired location', + fileName: backup.name, + lockParentWindow: true); + + if (outputFile == null) return; try { - await backup.file.copy(outputFile!); + await backup.file.copy(outputFile); } catch (exception, stackTrace) { await ExceptionHandler.onError(FlutterErrorDetails( exception: exception, diff --git a/lib/src/screens/seed/wallet_seed_page.dart b/lib/src/screens/seed/wallet_seed_page.dart index f0794f98a..97da1e027 100644 --- a/lib/src/screens/seed/wallet_seed_page.dart +++ b/lib/src/screens/seed/wallet_seed_page.dart @@ -158,6 +158,7 @@ class WalletSeedPage extends BasePage { final path = await FilePicker.platform.saveFile( dialogTitle: "Save seed as", fileName: "${walletSeedViewModel.name}-seed.txt", + lockParentWindow: true, ); if(path != null) { final file = File(path); diff --git a/lib/src/screens/settings/mweb_logs_page.dart b/lib/src/screens/settings/mweb_logs_page.dart index 8310673c5..6fd6ead3e 100644 --- a/lib/src/screens/settings/mweb_logs_page.dart +++ b/lib/src/screens/settings/mweb_logs_page.dart @@ -104,12 +104,17 @@ class MwebLogsPage extends BasePage { Future _saveFile() async { String? outputFile = await FilePicker.platform - .saveFile(dialogTitle: 'Save Your File to desired location', fileName: "debug.log"); + .saveFile( + dialogTitle: 'Save Your File to desired location', + fileName: "debug.log", + lockParentWindow: true); + + if (outputFile == null) return; try { final filePath = (await getApplicationSupportDirectory()).path + "/debug.log"; File debugLogFile = File(filePath); - await debugLogFile.copy(outputFile!); + await debugLogFile.copy(outputFile); } catch (exception, stackTrace) { ExceptionHandler.onError(FlutterErrorDetails( exception: exception, diff --git a/lib/src/screens/settings/silent_payments_logs_page.dart b/lib/src/screens/settings/silent_payments_logs_page.dart index baea684b6..102755f4e 100644 --- a/lib/src/screens/settings/silent_payments_logs_page.dart +++ b/lib/src/screens/settings/silent_payments_logs_page.dart @@ -106,12 +106,17 @@ class SilentPaymentsLogPage extends BasePage { Future _saveFile() async { String? outputFile = await FilePicker.platform - .saveFile(dialogTitle: 'Save Your File to desired location', fileName: "debug.log"); + .saveFile( + dialogTitle: 'Save Your File to desired location', + fileName: "debug.log", + lockParentWindow: true); + + if (outputFile == null) return; try { final filePath = (await getApplicationSupportDirectory()).path + "/debug.log"; File debugLogFile = File(filePath); - await debugLogFile.copy(outputFile!); + await debugLogFile.copy(outputFile); } catch (exception, stackTrace) { ExceptionHandler.onError(FlutterErrorDetails( exception: exception,