Skip to content

Commit

Permalink
fix: android invalid download location Download not starting or not e…
Browse files Browse the repository at this point in the history
…xplaining error #720
  • Loading branch information
KRTirtho committed Oct 29, 2023
1 parent 433ae3d commit d056dbf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/pages/settings/settings.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:collection/collection.dart';
import 'package:file_picker/file_picker.dart';
import 'package:file_selector/file_selector.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -47,15 +48,19 @@ class SettingsPage extends HookConsumerWidget {
}, []);

final pickDownloadLocation = useCallback(() async {
String? dirStr = await getDirectoryPath(
initialDirectory: preferences.downloadLocation,
);
if (dirStr == null) return;
if (DesktopTools.platform.isAndroid && dirStr.startsWith("content://")) {
dirStr =
"/storage/emulated/0/${Uri.decodeFull(dirStr).split("primary:").last}";
if (DesktopTools.platform.isMobile) {
final dirStr = await FilePicker.platform.getDirectoryPath(
initialDirectory: preferences.downloadLocation,
);
if (dirStr == null) return;
preferences.setDownloadLocation(dirStr);
} else {
String? dirStr = await getDirectoryPath(
initialDirectory: preferences.downloadLocation,
);
if (dirStr == null) return;
preferences.setDownloadLocation(dirStr);
}
preferences.setDownloadLocation(dirStr);
}, [preferences.downloadLocation]);

return SafeArea(
Expand Down
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.1.4"
file_picker:
dependency: "direct main"
description:
name: file_picker
sha256: "903dd4ba13eae7cef64acc480e91bf54c3ddd23b5b90b639c170f3911e489620"
url: "https://pub.dev"
source: hosted
version: "6.0.0"
file_selector:
dependency: "direct main"
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ dependencies:
youtube_explode_dart: ^2.0.1
simple_icons: ^7.10.0
audio_service_mpris: ^0.1.0
file_picker: ^6.0.0

dev_dependencies:
build_runner: ^2.3.2
Expand Down

0 comments on commit d056dbf

Please sign in to comment.