From 02b3056a1e5f91ccb744d78d0df39bef14b3e264 Mon Sep 17 00:00:00 2001 From: Miguel Ruivo Date: Mon, 4 May 2020 23:03:57 +0100 Subject: [PATCH] Adds temporary workaround due to Flutter issue #49364 --- CHANGELOG.md | 3 +++ .../mr/flutter/plugin/filepicker/FilePickerDelegate.java | 7 ++++++- pubspec.yaml | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c95196..956af05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.9.0+1 +Adds a temporary workaround on Android where it can trigger `onRequestPermissionsResult` twice, related to Flutter issue [49365](https://github.com/flutter/flutter/issues/49365) for anyone affected in Flutter versions below 1.14.6. + ## 1.9.0 Adds `clearTemporaryFiles()` that allows you to explicitly remove cached files — on Android applies typically to those picked from remote providers, on iOS _all_ picked files are cached. diff --git a/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerDelegate.java b/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerDelegate.java index 6b61dfa..16ed4eb 100644 --- a/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerDelegate.java +++ b/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerDelegate.java @@ -155,9 +155,14 @@ public class FilePickerDelegate implements PluginRegistry.ActivityResultListener private void startFileExplorer() { final Intent intent; + // Temporary fix, remove this null-check after Flutter Engine 1.14 has landed on stable + if (type == null) { + return; + } + intent = new Intent(Intent.ACTION_GET_CONTENT); final Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath() + File.separator); - Log.d(TAG, "Type" + type); + Log.d(TAG, "Selected type " + type); intent.setDataAndType(uri, this.type); intent.setType(this.type); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, this.isMultipleSelection); diff --git a/pubspec.yaml b/pubspec.yaml index ec3a9cd..2019022 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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.9.0 +version: 1.9.0+1 dependencies: flutter: