Fixes picking paths from Downloads directory on versions below SDK 29
This commit is contained in:
parent
506cf55516
commit
0d8c62b4f7
|
@ -1,3 +1,6 @@
|
|||
## 1.13.2
|
||||
Android: fixes picking paths from Downloads directory on versions below Android Q.
|
||||
|
||||
## 1.13.1
|
||||
Android: adds support to non-legacy picking on Android Q or above (thank you @lakshyab1995).
|
||||
|
||||
|
|
|
@ -92,6 +92,9 @@ public class FilePickerDelegate implements PluginRegistry.ActivityResultListener
|
|||
path = FileUtils.getUriFromRemote(FilePickerDelegate.this.activity, currentUri);
|
||||
} else {
|
||||
path = FileUtils.getPath(currentUri, FilePickerDelegate.this.activity);
|
||||
if (path == null) {
|
||||
path = FileUtils.getUriFromRemote(FilePickerDelegate.this.activity, currentUri);
|
||||
}
|
||||
}
|
||||
paths.add(path);
|
||||
Log.i(FilePickerDelegate.TAG, "[MultiFilePick] File #" + currentItem + " - URI: " + currentUri.getPath());
|
||||
|
@ -115,6 +118,9 @@ public class FilePickerDelegate implements PluginRegistry.ActivityResultListener
|
|||
fullPath = type.equals("dir") ? FileUtils.getFullPathFromTreeUri(uri, activity) : FileUtils.getUriFromRemote(FilePickerDelegate.this.activity, uri);
|
||||
} else {
|
||||
fullPath = FileUtils.getPath(uri, FilePickerDelegate.this.activity);
|
||||
if (fullPath == null) {
|
||||
fullPath = type.equals("dir") ? FileUtils.getFullPathFromTreeUri(uri, activity) : FileUtils.getUriFromRemote(FilePickerDelegate.this.activity, uri);
|
||||
}
|
||||
}
|
||||
|
||||
if (fullPath != null) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
name: file_picker
|
||||
description: A package that allows you to use a native file explorer to pick single or multiple absolute file paths, with extension filtering support.
|
||||
homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker
|
||||
version: 1.13.1
|
||||
version: 1.13.2
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
|
|
|
@ -17,8 +17,10 @@ class FilePicker extends FilePickerPlatform {
|
|||
/// [allowedExtensions] can be used (eg. `[.jpg, .pdf]`) to restrict picking types
|
||||
///
|
||||
/// Returns a `List<html.File>`
|
||||
static Future<List<html.File>> getMultiFile({FileType type = FileType.any, List<String> allowedExtensions}) async {
|
||||
return await _instance.getFiles(type: type, allowMultiple: true, allowedExtensions: allowedExtensions);
|
||||
static Future<List<html.File>> getMultiFile(
|
||||
{FileType type = FileType.any, List<String> allowedExtensions}) async {
|
||||
return await _instance.getFiles(
|
||||
type: type, allowMultiple: true, allowedExtensions: allowedExtensions);
|
||||
}
|
||||
|
||||
/// Opens browser file picker window to select a single file.
|
||||
|
@ -26,8 +28,11 @@ class FilePicker extends FilePickerPlatform {
|
|||
/// [allowedExtensions] can be used (eg. `[.jpg, .pdf]`) to restrict picking types
|
||||
///
|
||||
/// Returns a `html.File`
|
||||
static Future<html.File> getFile({FileType type = FileType.any, List<String> allowedExtensions}) async {
|
||||
return (await _instance.getFiles(type: type, allowedExtensions: allowedExtensions)).first;
|
||||
static Future<html.File> getFile(
|
||||
{FileType type = FileType.any, List<String> allowedExtensions}) async {
|
||||
return (await _instance.getFiles(
|
||||
type: type, allowedExtensions: allowedExtensions))
|
||||
.first;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -41,7 +46,8 @@ class FilePicker extends FilePickerPlatform {
|
|||
html.InputElement uploadInput = html.FileUploadInputElement();
|
||||
uploadInput.multiple = allowMultiple;
|
||||
uploadInput.accept = _fileType(type, allowedExtensions);
|
||||
uploadInput.onChange.listen((event) => pickedFiles.complete(uploadInput.files));
|
||||
uploadInput.onChange
|
||||
.listen((event) => pickedFiles.complete(uploadInput.files));
|
||||
uploadInput.click();
|
||||
return await pickedFiles.future;
|
||||
}
|
||||
|
@ -64,7 +70,8 @@ class FilePicker extends FilePickerPlatform {
|
|||
return 'video/*|image/*';
|
||||
|
||||
case FileType.custom:
|
||||
return allowedExtensions.fold('', (prev, next) => '${prev.isEmpty ? '' : '$prev,'} .$next');
|
||||
return allowedExtensions.fold(
|
||||
'', (prev, next) => '${prev.isEmpty ? '' : '$prev,'} .$next');
|
||||
break;
|
||||
}
|
||||
return '';
|
||||
|
|
Loading…
Reference in New Issue