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
Anton Schmidt committed
May 7, 2026 at 04:44 UTC
b142c34f0fd8e5fe71bf1dbe927828e6a40d7ea3
4 files changed
+22
-6
lib/src/screens/backup/backup_page.dart
+7
-2
@@ -172,10 +172,15 @@ class BackupPage extends BasePage {
172
173
Future<void> _saveFile(BackupExportFile backup) async {
174
String? outputFile = await FilePicker.platform
175
- .saveFile(dialogTitle: 'Save Your File to desired location', fileName: backup.name);
175
+ .saveFile(
176
+ dialogTitle: 'Save Your File to desired location',
177
+ fileName: backup.name,
178
+ lockParentWindow: true);
179
+
180
+ if (outputFile == null) return;
181
182
try {
178
- await backup.file.copy(outputFile!);
183
+ await backup.file.copy(outputFile);
184
} catch (exception, stackTrace) {
185
await ExceptionHandler.onError(FlutterErrorDetails(
186
exception: exception,
lib/src/screens/seed/wallet_seed_page.dart
+1
@@ -158,6 +158,7 @@ class WalletSeedPage extends BasePage {
158
final path = await FilePicker.platform.saveFile(
159
dialogTitle: "Save seed as",
160
fileName: "${walletSeedViewModel.name}-seed.txt",
161
+ lockParentWindow: true,
162
);
163
if(path != null) {
164
final file = File(path);
lib/src/screens/settings/mweb_logs_page.dart
+7
-2
@@ -104,12 +104,17 @@ class MwebLogsPage extends BasePage {
104
105
Future<void> _saveFile() async {
106
String? outputFile = await FilePicker.platform
107
- .saveFile(dialogTitle: 'Save Your File to desired location', fileName: "debug.log");
107
+ .saveFile(
108
+ dialogTitle: 'Save Your File to desired location',
109
+ fileName: "debug.log",
110
+ lockParentWindow: true);
111
+
112
+ if (outputFile == null) return;
113
114
try {
115
final filePath = (await getApplicationSupportDirectory()).path + "/debug.log";
116
File debugLogFile = File(filePath);
112
- await debugLogFile.copy(outputFile!);
117
+ await debugLogFile.copy(outputFile);
118
} catch (exception, stackTrace) {
119
ExceptionHandler.onError(FlutterErrorDetails(
120
exception: exception,
lib/src/screens/settings/silent_payments_logs_page.dart
+7
-2
@@ -106,12 +106,17 @@ class SilentPaymentsLogPage extends BasePage {
106
107
Future<void> _saveFile() async {
108
String? outputFile = await FilePicker.platform
109
- .saveFile(dialogTitle: 'Save Your File to desired location', fileName: "debug.log");
109
+ .saveFile(
110
+ dialogTitle: 'Save Your File to desired location',
111
+ fileName: "debug.log",
112
+ lockParentWindow: true);
113
+
114
+ if (outputFile == null) return;
115
116
try {
117
final filePath = (await getApplicationSupportDirectory()).path + "/debug.log";
118
File debugLogFile = File(filePath);
114
- await debugLogFile.copy(outputFile!);
119
+ await debugLogFile.copy(outputFile);
120
} catch (exception, stackTrace) {
121
ExceptionHandler.onError(FlutterErrorDetails(
122
exception: exception,