Update downloader_menu.dart
This commit is contained in:
parent
058d025aaa
commit
df334f770b
|
|
@ -16,13 +16,18 @@ class DownloaderMenu extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DownloaderMenuState extends State<DownloaderMenu> with PreferencesMixin {
|
class _DownloaderMenuState extends State<DownloaderMenu> with PreferencesMixin {
|
||||||
|
String _currentPath = Directory.current.path;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
getPreference<String>(prefWorkingDirectory).then((pref) {
|
getPreference<String>(prefWorkingDirectory).then((pref) {
|
||||||
setState(() {
|
if (pref != null && pref.isNotEmpty && Directory(pref).existsSync()) {
|
||||||
Directory.current = pref;
|
setState(() {
|
||||||
});
|
Directory.current = pref;
|
||||||
|
_currentPath = pref;
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,9 +49,7 @@ class _DownloaderMenuState extends State<DownloaderMenu> with PreferencesMixin {
|
||||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(width: 8),
|
||||||
width: 8,
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
||||||
|
|
@ -55,22 +58,20 @@ class _DownloaderMenuState extends State<DownloaderMenu> with PreferencesMixin {
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var folder = await FilePicker.platform
|
var folder = await FilePicker.platform
|
||||||
.getDirectoryPath(dialogTitle: "Pick a folder");
|
.getDirectoryPath(dialogTitle: "Pick a folder");
|
||||||
if (folder != null) {
|
if (folder != null && folder.isNotEmpty) {
|
||||||
setState(() {
|
setState(() {
|
||||||
Directory.current = folder;
|
Directory.current = folder;
|
||||||
|
_currentPath = folder;
|
||||||
});
|
});
|
||||||
savePreference(
|
savePreference(prefWorkingDirectory, folder);
|
||||||
prefWorkingDirectory, Directory.current.path);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text(Directory.current.path),
|
child: Text(_currentPath),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(thickness: 2),
|
||||||
thickness: 2,
|
|
||||||
),
|
|
||||||
const Row(
|
const Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue