mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
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:
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user