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
This commit is contained in:
Anton Schmidt
2026-05-07 04:44:46 +02:00
committed by GitHub
parent 3822a2c30f
commit b142c34f0f
4 changed files with 22 additions and 6 deletions
+7 -2
View File
@@ -172,10 +172,15 @@ class BackupPage extends BasePage {
Future<void> _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,
@@ -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);
+7 -2
View File
@@ -104,12 +104,17 @@ class MwebLogsPage extends BasePage {
Future<void> _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,
@@ -106,12 +106,17 @@ class SilentPaymentsLogPage extends BasePage {
Future<void> _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,