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: