From 8243eb1a86a89d41ac60b0375f4f738dafe229ab Mon Sep 17 00:00:00 2001
From: julian <julian@cypherstack.com>
Date: Fri, 30 Sep 2022 18:46:52 -0600
Subject: [PATCH] Don't ask android where to save

---
 .../advanced_views/debug_view.dart            |  44 +++--
 .../create_auto_backup_view.dart              | 132 +++++++------
 .../create_backup_view.dart                   | 181 ++++++++++--------
 .../edit_auto_backup_view.dart                | 131 +++++++------
 .../helpers/stack_file_system.dart            |   3 +-
 .../restore_from_file_view.dart               |  31 +--
 lib/services/debug_service.dart               |   4 +-
 7 files changed, 300 insertions(+), 226 deletions(-)

diff --git a/lib/pages/settings_views/global_settings_view/advanced_views/debug_view.dart b/lib/pages/settings_views/global_settings_view/advanced_views/debug_view.dart
index 6b073ea69..29baad1c6 100644
--- a/lib/pages/settings_views/global_settings_view/advanced_views/debug_view.dart
+++ b/lib/pages/settings_views/global_settings_view/advanced_views/debug_view.dart
@@ -303,13 +303,17 @@ class _DebugViewState extends ConsumerState<DebugView> {
                                   Logging.instance
                                       .log("$e\n$s", level: LogLevel.Error);
                                 }
-
-                                final String? path =
-                                    await FilePicker.platform.getDirectoryPath(
-                                  dialogTitle: "Choose Backup location",
-                                  initialDirectory: dir.path,
-                                  lockParentWindow: true,
-                                );
+                                String? path;
+                                if (Platform.isAndroid) {
+                                  path = dir.path;
+                                } else {
+                                  path = await FilePicker.platform
+                                      .getDirectoryPath(
+                                    dialogTitle: "Choose Backup location",
+                                    initialDirectory: dir.path,
+                                    lockParentWindow: true,
+                                  );
+                                }
 
                                 if (path != null) {
                                   final eventBus = EventBus();
@@ -328,7 +332,7 @@ class _DebugViewState extends ConsumerState<DebugView> {
                                     ),
                                   ));
 
-                                  await ref
+                                  final filename = await ref
                                       .read(debugServiceProvider)
                                       .exportToFile(path, eventBus);
 
@@ -336,10 +340,26 @@ class _DebugViewState extends ConsumerState<DebugView> {
 
                                   if (mounted) {
                                     Navigator.pop(context);
-                                    unawaited(showFloatingFlushBar(
-                                        type: FlushBarType.info,
-                                        context: context,
-                                        message: 'Logs file saved'));
+
+                                    if (Platform.isAndroid) {
+                                      unawaited(
+                                        showDialog(
+                                          context: context,
+                                          builder: (context) => StackOkDialog(
+                                            title: "Logs saved to",
+                                            message: "${path!}/$filename",
+                                          ),
+                                        ),
+                                      );
+                                    } else {
+                                      unawaited(
+                                        showFloatingFlushBar(
+                                          type: FlushBarType.info,
+                                          context: context,
+                                          message: 'Logs file saved',
+                                        ),
+                                      );
+                                    }
                                   }
                                 }
                               },
diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/create_auto_backup_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/create_auto_backup_view.dart
index 22ace0a8e..b44a473b4 100644
--- a/lib/pages/settings_views/global_settings_view/stack_backup_views/create_auto_backup_view.dart
+++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/create_auto_backup_view.dart
@@ -82,6 +82,17 @@ class _EnableAutoBackupViewState extends ConsumerState<CreateAutoBackupView> {
     passwordFocusNode = FocusNode();
     passwordRepeatFocusNode = FocusNode();
 
+    if (Platform.isAndroid) {
+      WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
+        final dir = await stackFileSystem.prepareStorage();
+        if (mounted) {
+          setState(() {
+            fileLocationController.text = dir.path;
+          });
+        }
+      });
+    }
+
     super.initState();
   }
 
@@ -133,64 +144,70 @@ class _EnableAutoBackupViewState extends ConsumerState<CreateAutoBackupView> {
                     const SizedBox(
                       height: 10,
                     ),
-                    TextField(
-                      onTap: () async {
-                        try {
-                          await stackFileSystem.prepareStorage();
+                    if (!Platform.isAndroid)
+                      TextField(
+                        onTap: Platform.isAndroid
+                            ? null
+                            : () async {
+                                try {
+                                  await stackFileSystem.prepareStorage();
 
-                          if (mounted) {
-                            await stackFileSystem.pickDir(context);
-                          }
+                                  if (mounted) {
+                                    await stackFileSystem.pickDir(context);
+                                  }
 
-                          if (mounted) {
-                            setState(() {
-                              fileLocationController.text =
-                                  stackFileSystem.dirPath ?? "";
-                            });
-                          }
-                        } catch (e, s) {
-                          Logging.instance.log("$e\n$s", level: LogLevel.Error);
-                        }
-                      },
-                      controller: fileLocationController,
-                      style: STextStyles.field(context),
-                      decoration: InputDecoration(
-                        hintText: "Save to...",
-                        suffixIcon: UnconstrainedBox(
-                          child: Row(
-                            children: [
-                              const SizedBox(
-                                width: 16,
-                              ),
-                              SvgPicture.asset(
-                                Assets.svg.folder,
-                                color: Theme.of(context)
-                                    .extension<StackColors>()!
-                                    .textDark3,
-                                width: 16,
-                                height: 16,
-                              ),
-                              const SizedBox(
-                                width: 12,
-                              ),
-                            ],
+                                  if (mounted) {
+                                    setState(() {
+                                      fileLocationController.text =
+                                          stackFileSystem.dirPath ?? "";
+                                    });
+                                  }
+                                } catch (e, s) {
+                                  Logging.instance
+                                      .log("$e\n$s", level: LogLevel.Error);
+                                }
+                              },
+                        controller: fileLocationController,
+                        style: STextStyles.field(context),
+                        decoration: InputDecoration(
+                          hintText: "Save to...",
+                          hintStyle: STextStyles.fieldLabel(context),
+                          suffixIcon: UnconstrainedBox(
+                            child: Row(
+                              children: [
+                                const SizedBox(
+                                  width: 16,
+                                ),
+                                SvgPicture.asset(
+                                  Assets.svg.folder,
+                                  color: Theme.of(context)
+                                      .extension<StackColors>()!
+                                      .textDark3,
+                                  width: 16,
+                                  height: 16,
+                                ),
+                                const SizedBox(
+                                  width: 12,
+                                ),
+                              ],
+                            ),
                           ),
                         ),
+                        key: const Key(
+                            "createBackupSaveToFileLocationTextFieldKey"),
+                        readOnly: true,
+                        toolbarOptions: const ToolbarOptions(
+                          copy: true,
+                          cut: false,
+                          paste: false,
+                          selectAll: false,
+                        ),
+                        onChanged: (newValue) {},
                       ),
-                      key: const Key(
-                          "createBackupSaveToFileLocationTextFieldKey"),
-                      readOnly: true,
-                      toolbarOptions: const ToolbarOptions(
-                        copy: true,
-                        cut: false,
-                        paste: false,
-                        selectAll: false,
+                    if (!Platform.isAndroid)
+                      const SizedBox(
+                        height: 10,
                       ),
-                      onChanged: (newValue) {},
-                    ),
-                    const SizedBox(
-                      height: 10,
-                    ),
                     ClipRRect(
                       borderRadius: BorderRadius.circular(
                         Constants.size.circularBorderRadius,
@@ -593,8 +610,15 @@ class _EnableAutoBackupViewState extends ConsumerState<CreateAutoBackupView> {
                                   await showDialog<dynamic>(
                                     context: context,
                                     barrierDismissible: false,
-                                    builder: (_) => const StackOkDialog(
-                                        title: "Stack Auto Backup enabled!"),
+                                    builder: (_) => Platform.isAndroid
+                                        ? StackOkDialog(
+                                            title:
+                                                "Stack Auto Backup enabled and saved to:",
+                                            message: fileToSave,
+                                          )
+                                        : const StackOkDialog(
+                                            title:
+                                                "Stack Auto Backup enabled!"),
                                   );
                                   if (mounted) {
                                     passwordController.text = "";
diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart
index 964111cd3..8dfc7588c 100644
--- a/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart
+++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart
@@ -64,6 +64,17 @@ class _RestoreFromFileViewState extends State<CreateBackupView> {
     passwordFocusNode = FocusNode();
     passwordRepeatFocusNode = FocusNode();
 
+    if (Platform.isAndroid) {
+      WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
+        final dir = await stackFileSystem.prepareStorage();
+        if (mounted) {
+          setState(() {
+            fileLocationController.text = dir.path;
+          });
+        }
+      });
+    }
+
     super.initState();
   }
 
@@ -113,88 +124,78 @@ class _RestoreFromFileViewState extends State<CreateBackupView> {
                   child: Column(
                     crossAxisAlignment: CrossAxisAlignment.stretch,
                     children: [
-                      Consumer(builder: (context, ref, __) {
-                        return Container(
-                          color: Colors.transparent,
-                          child: TextField(
-                            onTap: () async {
-                              try {
-                                await stackFileSystem.prepareStorage();
-                                // ref
-                                //     .read(
-                                //         shouldShowLockscreenOnResumeStateProvider
-                                //             .state)
-                                //     .state = false;
-                                if (mounted) {
-                                  await stackFileSystem.pickDir(context);
-                                }
+                      if (!Platform.isAndroid)
+                        Consumer(builder: (context, ref, __) {
+                          return Container(
+                            color: Colors.transparent,
+                            child: TextField(
+                              onTap: Platform.isAndroid
+                                  ? null
+                                  : () async {
+                                      try {
+                                        await stackFileSystem.prepareStorage();
 
-                                // Future<void>.delayed(
-                                //   const Duration(seconds: 2),
-                                //   () => ref
-                                //       .read(
-                                //           shouldShowLockscreenOnResumeStateProvider
-                                //               .state)
-                                //       .state = true,
-                                // );
+                                        if (mounted) {
+                                          await stackFileSystem
+                                              .pickDir(context);
+                                        }
 
-                                setState(() {
-                                  fileLocationController.text =
-                                      stackFileSystem.dirPath ?? "";
-                                });
-                              } catch (e, s) {
-                                // ref
-                                //     .read(
-                                //         shouldShowLockscreenOnResumeStateProvider
-                                //             .state)
-                                //     .state = true;
-                                Logging.instance
-                                    .log("$e\n$s", level: LogLevel.Error);
-                              }
-                            },
-                            controller: fileLocationController,
-                            style: STextStyles.field(context),
-                            decoration: InputDecoration(
-                              hintText: "Save to...",
-                              suffixIcon: UnconstrainedBox(
-                                child: Row(
-                                  children: [
-                                    const SizedBox(
-                                      width: 16,
-                                    ),
-                                    SvgPicture.asset(
-                                      Assets.svg.folder,
-                                      color: Theme.of(context)
-                                          .extension<StackColors>()!
-                                          .textDark3,
-                                      width: 16,
-                                      height: 16,
-                                    ),
-                                    const SizedBox(
-                                      width: 12,
-                                    ),
-                                  ],
+                                        if (mounted) {
+                                          setState(() {
+                                            fileLocationController.text =
+                                                stackFileSystem.dirPath ?? "";
+                                          });
+                                        }
+                                      } catch (e, s) {
+                                        Logging.instance.log("$e\n$s",
+                                            level: LogLevel.Error);
+                                      }
+                                    },
+                              controller: fileLocationController,
+                              style: STextStyles.field(context),
+                              decoration: InputDecoration(
+                                hintText: "Save to...",
+                                hintStyle: STextStyles.fieldLabel(context),
+                                suffixIcon: UnconstrainedBox(
+                                  child: Row(
+                                    children: [
+                                      const SizedBox(
+                                        width: 16,
+                                      ),
+                                      SvgPicture.asset(
+                                        Assets.svg.folder,
+                                        color: Theme.of(context)
+                                            .extension<StackColors>()!
+                                            .textDark3,
+                                        width: 16,
+                                        height: 16,
+                                      ),
+                                      const SizedBox(
+                                        width: 12,
+                                      ),
+                                    ],
+                                  ),
                                 ),
                               ),
+                              key: const Key(
+                                  "createBackupSaveToFileLocationTextFieldKey"),
+                              readOnly: true,
+                              toolbarOptions: const ToolbarOptions(
+                                copy: true,
+                                cut: false,
+                                paste: false,
+                                selectAll: false,
+                              ),
+                              onChanged: (newValue) {
+                                // ref.read(addressEntryDataProvider(widget.id)).address = newValue;
+                              },
                             ),
-                            key: const Key(
-                                "createBackupSaveToFileLocationTextFieldKey"),
-                            readOnly: true,
-                            toolbarOptions: const ToolbarOptions(
-                              copy: true,
-                              cut: false,
-                              paste: false,
-                              selectAll: false,
-                            ),
-                            onChanged: (newValue) {
-                              // ref.read(addressEntryDataProvider(widget.id)).address = newValue;
-                            },
-                          ),
-                        );
-                      }),
-                      const SizedBox(
-                        height: 8,
-                      ),
+                          );
+                        }),
+                      if (!Platform.isAndroid)
+                        const SizedBox(
+                          height: 8,
+                        ),
                       ClipRRect(
                         borderRadius: BorderRadius.circular(
                           Constants.size.circularBorderRadius,
@@ -315,8 +316,12 @@ class _RestoreFromFileViewState extends State<CreateBackupView> {
                                     .extension<StackColors>()!
                                     .accentColorRed
                                 : passwordStrength < 1
-                                    ? Theme.of(context).extension<StackColors>()!.accentColorYellow
-                                    : Theme.of(context).extension<StackColors>()!.accentColorGreen,
+                                    ? Theme.of(context)
+                                        .extension<StackColors>()!
+                                        .accentColorYellow
+                                    : Theme.of(context)
+                                        .extension<StackColors>()!
+                                        .accentColorGreen,
                             backgroundColor: Theme.of(context)
                                 .extension<StackColors>()!
                                 .buttonBackSecondary,
@@ -389,8 +394,12 @@ class _RestoreFromFileViewState extends State<CreateBackupView> {
                       const Spacer(),
                       TextButton(
                         style: shouldEnableCreate
-                            ? Theme.of(context) .extension<StackColors>()!.getPrimaryEnabledButtonColor(context)
-                            : Theme.of(context) .extension<StackColors>()!.getPrimaryDisabledButtonColor(context),
+                            ? Theme.of(context)
+                                .extension<StackColors>()!
+                                .getPrimaryEnabledButtonColor(context)
+                            : Theme.of(context)
+                                .extension<StackColors>()!
+                                .getPrimaryDisabledButtonColor(context),
                         onPressed: !shouldEnableCreate
                             ? null
                             : () async {
@@ -468,8 +477,14 @@ class _RestoreFromFileViewState extends State<CreateBackupView> {
                                     await showDialog<dynamic>(
                                       context: context,
                                       barrierDismissible: false,
-                                      builder: (_) => const StackOkDialog(
-                                          title: "Backup creation succeeded"),
+                                      builder: (_) => Platform.isAndroid
+                                          ? StackOkDialog(
+                                              title: "Backup saved to:",
+                                              message: fileToSave,
+                                            )
+                                          : const StackOkDialog(
+                                              title:
+                                                  "Backup creation succeeded"),
                                     );
                                     passwordController.text = "";
                                     passwordRepeatController.text = "";
diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart
index fa14358ea..9368d3b77 100644
--- a/lib/pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart
+++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart
@@ -84,6 +84,17 @@ class _EditAutoBackupViewState extends ConsumerState<EditAutoBackupView> {
     passwordFocusNode = FocusNode();
     passwordRepeatFocusNode = FocusNode();
 
+    if (Platform.isAndroid) {
+      WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
+        final dir = await stackFileSystem.prepareStorage();
+        if (mounted) {
+          setState(() {
+            fileLocationController.text = dir.path;
+          });
+        }
+      });
+    }
+
     super.initState();
   }
 
@@ -135,64 +146,70 @@ class _EditAutoBackupViewState extends ConsumerState<EditAutoBackupView> {
                     const SizedBox(
                       height: 10,
                     ),
-                    TextField(
-                      onTap: () async {
-                        try {
-                          await stackFileSystem.prepareStorage();
+                    if (!Platform.isAndroid)
+                      TextField(
+                        onTap: Platform.isAndroid
+                            ? null
+                            : () async {
+                                try {
+                                  await stackFileSystem.prepareStorage();
 
-                          if (mounted) {
-                            await stackFileSystem.pickDir(context);
-                          }
+                                  if (mounted) {
+                                    await stackFileSystem.pickDir(context);
+                                  }
 
-                          if (mounted) {
-                            setState(() {
-                              fileLocationController.text =
-                                  stackFileSystem.dirPath ?? "";
-                            });
-                          }
-                        } catch (e, s) {
-                          Logging.instance.log("$e\n$s", level: LogLevel.Error);
-                        }
-                      },
-                      controller: fileLocationController,
-                      style: STextStyles.field(context),
-                      decoration: InputDecoration(
-                        hintText: "Save to...",
-                        suffixIcon: UnconstrainedBox(
-                          child: Row(
-                            children: [
-                              const SizedBox(
-                                width: 16,
-                              ),
-                              SvgPicture.asset(
-                                Assets.svg.folder,
-                                color: Theme.of(context)
-                                    .extension<StackColors>()!
-                                    .textDark3,
-                                width: 16,
-                                height: 16,
-                              ),
-                              const SizedBox(
-                                width: 12,
-                              ),
-                            ],
+                                  if (mounted) {
+                                    setState(() {
+                                      fileLocationController.text =
+                                          stackFileSystem.dirPath ?? "";
+                                    });
+                                  }
+                                } catch (e, s) {
+                                  Logging.instance
+                                      .log("$e\n$s", level: LogLevel.Error);
+                                }
+                              },
+                        controller: fileLocationController,
+                        style: STextStyles.field(context),
+                        decoration: InputDecoration(
+                          hintText: "Save to...",
+                          hintStyle: STextStyles.fieldLabel(context),
+                          suffixIcon: UnconstrainedBox(
+                            child: Row(
+                              children: [
+                                const SizedBox(
+                                  width: 16,
+                                ),
+                                SvgPicture.asset(
+                                  Assets.svg.folder,
+                                  color: Theme.of(context)
+                                      .extension<StackColors>()!
+                                      .textDark3,
+                                  width: 16,
+                                  height: 16,
+                                ),
+                                const SizedBox(
+                                  width: 12,
+                                ),
+                              ],
+                            ),
                           ),
                         ),
+                        key: const Key(
+                            "createBackupSaveToFileLocationTextFieldKey"),
+                        readOnly: true,
+                        toolbarOptions: const ToolbarOptions(
+                          copy: true,
+                          cut: false,
+                          paste: false,
+                          selectAll: false,
+                        ),
+                        onChanged: (newValue) {},
                       ),
-                      key: const Key(
-                          "createBackupSaveToFileLocationTextFieldKey"),
-                      readOnly: true,
-                      toolbarOptions: const ToolbarOptions(
-                        copy: true,
-                        cut: false,
-                        paste: false,
-                        selectAll: false,
+                    if (!Platform.isAndroid)
+                      const SizedBox(
+                        height: 10,
                       ),
-                      onChanged: (newValue) {},
-                    ),
-                    const SizedBox(
-                      height: 10,
-                    ),
                     ClipRRect(
                       borderRadius: BorderRadius.circular(
                         Constants.size.circularBorderRadius,
@@ -594,8 +611,14 @@ class _EditAutoBackupViewState extends ConsumerState<EditAutoBackupView> {
                                   await showDialog<dynamic>(
                                     context: context,
                                     barrierDismissible: false,
-                                    builder: (_) => const StackOkDialog(
-                                        title: "Stack Auto Backup saved"),
+                                    builder: (_) => Platform.isAndroid
+                                        ? StackOkDialog(
+                                            title:
+                                                "Stack Auto Backup saved to:",
+                                            message: fileToSave,
+                                          )
+                                        : const StackOkDialog(
+                                            title: "Stack Auto Backup saved"),
                                   );
                                   if (mounted) {
                                     passwordController.text = "";
diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/stack_file_system.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/stack_file_system.dart
index 75f2b272f..3196938da 100644
--- a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/stack_file_system.dart
+++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/stack_file_system.dart
@@ -13,7 +13,7 @@ class StackFileSystem {
 
   final bool isDesktop = !(Platform.isAndroid || Platform.isIOS);
 
-  Future<void> prepareStorage() async {
+  Future<Directory> prepareStorage() async {
     rootPath = (await getApplicationDocumentsDirectory());
     debugPrint(rootPath!.absolute.toString());
     if (Platform.isAndroid) {
@@ -47,6 +47,7 @@ class StackFileSystem {
       debugPrint("$e $s");
     }
     startPath = sampleFolder;
+    return sampleFolder;
   }
 
   Future<void> pickDir(BuildContext context) async {
diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart
index feda62d0a..cec114023 100644
--- a/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart
+++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart
@@ -99,29 +99,17 @@ class _RestoreFromFileViewState extends ConsumerState<RestoreFromFileView> {
                         onTap: () async {
                           try {
                             await stackFileSystem.prepareStorage();
-                            // ref
-                            //     .read(shouldShowLockscreenOnResumeStateProvider
-                            //         .state)
-                            //     .state = false;
-                            await stackFileSystem.openFile(context);
+                            if (mounted) {
+                              await stackFileSystem.openFile(context);
+                            }
 
-                            // Future<void>.delayed(
-                            //   const Duration(seconds: 2),
-                            //   () => ref
-                            //       .read(
-                            //           shouldShowLockscreenOnResumeStateProvider
-                            //               .state)
-                            //       .state = true,
-                            // );
-
-                            fileLocationController.text =
-                                stackFileSystem.filePath ?? "";
-                            setState(() {});
+                            if (mounted) {
+                              setState(() {
+                                fileLocationController.text =
+                                    stackFileSystem.filePath ?? "";
+                              });
+                            }
                           } catch (e, s) {
-                            // ref
-                            //     .read(shouldShowLockscreenOnResumeStateProvider
-                            //         .state)
-                            //     .state = true;
                             Logging.instance
                                 .log("$e\n$s", level: LogLevel.Error);
                           }
@@ -130,6 +118,7 @@ class _RestoreFromFileViewState extends ConsumerState<RestoreFromFileView> {
                         style: STextStyles.field(context),
                         decoration: InputDecoration(
                           hintText: "Choose file...",
+                          hintStyle: STextStyles.fieldLabel(context),
                           suffixIcon: UnconstrainedBox(
                             child: Row(
                               children: [
diff --git a/lib/services/debug_service.dart b/lib/services/debug_service.dart
index e7347c6a3..c63e22cb2 100644
--- a/lib/services/debug_service.dart
+++ b/lib/services/debug_service.dart
@@ -75,7 +75,8 @@ class DebugService extends ChangeNotifier {
         level: LogLevel.Info);
   }
 
-  Future<void> exportToFile(String directory, EventBus eventBus) async {
+  /// returns the filename of the saved logs file
+  Future<String> exportToFile(String directory, EventBus eventBus) async {
     final now = DateTime.now();
     final filename =
         "Stack_Wallet_logs_${now.year}_${now.month}_${now.day}_${now.hour}_${now.minute}_${now.second}.txt";
@@ -99,5 +100,6 @@ class DebugService extends ChangeNotifier {
     await sink.close();
 
     eventBus.fire(1.0);
+    return filename;
   }
 }