From df334f770bf6d0a60f93862df9bdef525e65806a Mon Sep 17 00:00:00 2001 From: "S.B" <30941141+s-b-repo@users.noreply.github.com> Date: Sat, 3 Jan 2026 14:14:52 -0500 Subject: [PATCH] Update downloader_menu.dart --- .../widgets/home_page/downloader_menu.dart | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/src/widgets/home_page/downloader_menu.dart b/lib/src/widgets/home_page/downloader_menu.dart index 422652e..36261eb 100644 --- a/lib/src/widgets/home_page/downloader_menu.dart +++ b/lib/src/widgets/home_page/downloader_menu.dart @@ -16,13 +16,18 @@ class DownloaderMenu extends StatefulWidget { } class _DownloaderMenuState extends State with PreferencesMixin { + String _currentPath = Directory.current.path; + @override void initState() { super.initState(); getPreference(prefWorkingDirectory).then((pref) { - setState(() { - Directory.current = pref; - }); + if (pref != null && pref.isNotEmpty && Directory(pref).existsSync()) { + setState(() { + Directory.current = pref; + _currentPath = pref; + }); + } }); } @@ -44,9 +49,7 @@ class _DownloaderMenuState extends State with PreferencesMixin { color: Theme.of(context).colorScheme.onPrimaryContainer, ), ), - const SizedBox( - width: 8, - ), + const SizedBox(width: 8), ElevatedButton( style: ElevatedButton.styleFrom( foregroundColor: Theme.of(context).colorScheme.onSurface, @@ -55,22 +58,20 @@ class _DownloaderMenuState extends State with PreferencesMixin { onPressed: () async { var folder = await FilePicker.platform .getDirectoryPath(dialogTitle: "Pick a folder"); - if (folder != null) { + if (folder != null && folder.isNotEmpty) { setState(() { Directory.current = folder; + _currentPath = folder; }); - savePreference( - prefWorkingDirectory, Directory.current.path); + savePreference(prefWorkingDirectory, folder); } }, - child: Text(Directory.current.path), + child: Text(_currentPath), ), ], ), ), - const Divider( - thickness: 2, - ), + const Divider(thickness: 2), const Row( children: [ Expanded(