From 7751df32adfbc48fe4ce0eb25d835cd003617101 Mon Sep 17 00:00:00 2001 From: Miguel Ruivo Date: Sat, 20 Apr 2019 17:21:19 +0100 Subject: [PATCH] 1.3.3 > 1.3.4 (#71) * If file not choosen getFile() should return null * minor fix * fixes an issue where sometimes getFilePath could return a List instead of a String * minor fixes * Update README.md * Fix for background activities trying to register the plugin (#66) * Beta (#55) * If picker is canceled in `getFile()`, it should return `null` * Beta (#60) * Added a check to registerWith to prevent background flutter view from trying to register the plugin, as there won't be any activity. * 1.3.3 > 1.3.4 --- CHANGELOG.md | 4 ++++ README.md | 9 +++++++-- .../mr/flutter/plugin/filepicker/FilePickerPlugin.java | 7 +++++++ pubspec.yaml | 3 +-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c45a28..3652ff7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.4 + +**Bug fix:** Protects the `registrar.activity()` in the Android side of being accessed when it's `null`. + ## 1.3.3 **Bug fixes** diff --git a/README.md b/README.md index d71655d..4c5541f 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,15 @@ A package that allows you to use a native file explorer to pick single or multip First, add *file_picker* as a dependency in [your pubspec.yaml file](https://flutter.io/platform-plugins/). ``` -file_picker: ^1.3.3 +file_picker: ^1.3.4 ``` ### Android -Add `` to your app `AndroidManifest.xml` file. This is required due to file caching when a path is required from a remote file (eg. Google Drive). +Add +``` + + +``` +before `` to your app's `AndroidManifest.xml` file. This is required due to file caching when a path is required from a remote file (eg. Google Drive). ### iOS Based on the location of the files that you are willing to pick paths, you may need to add some keys to your iOS app's _Info.plist_ file, located in `/ios/Runner/Info.plist`: diff --git a/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java b/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java index 03f3be1..cced080 100644 --- a/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java +++ b/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java @@ -39,6 +39,13 @@ public class FilePickerPlugin implements MethodCallHandler { /** Plugin registration. */ public static void registerWith(Registrar registrar) { + + if (registrar.activity() == null) { + // If a background flutter view tries to register the plugin, there will be no activity from the registrar, + // we stop the registering process immediately because the ImagePicker requires an activity. + return; + } + final MethodChannel channel = new MethodChannel(registrar.messenger(), "file_picker"); channel.setMethodCallHandler(new FilePickerPlugin()); diff --git a/pubspec.yaml b/pubspec.yaml index 6abdcb2..9ec337f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,8 +2,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 extensions filtering support. author: Miguel Ruivo homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker -version: 1.3.3 - +version: 1.3.4 dependencies: flutter: