From 43796d2a2186b9d5c82dd383ab7dc7c276ceab51 Mon Sep 17 00:00:00 2001 From: Miguel Ruivo Date: Sat, 16 Mar 2019 12:18:10 +0000 Subject: [PATCH] Beta (#55) * If picker is canceled in `getFile()`, it should return `null` --- CHANGELOG.md | 4 ++++ README.md | 2 +- lib/file_picker.dart | 2 +- pubspec.yaml | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3435144..8711964 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.2 + +**Bug fix:** Returns a `null` value in the `getFile()` when the picker is canceled. + ## 1.3.1 **Bug fix:** Fixes an issue on Android, where other activity would try to call `FilePicker`'s result object when it shouldn't. diff --git a/README.md b/README.md index d1c335e..8c22b65 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ 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.1 +file_picker: ^1.3.2 ``` ### 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). diff --git a/lib/file_picker.dart b/lib/file_picker.dart index a81fa5b..afd965b 100644 --- a/lib/file_picker.dart +++ b/lib/file_picker.dart @@ -40,7 +40,7 @@ class FilePicker { /// you are planing to create a `File` for the returned path. static Future getFile({FileType type = FileType.ANY, String fileExtension}) async { final String filePath = await _getPath(_handleType(type, fileExtension), false); - return File(filePath); + return filePath != null ? File(filePath) : null; } static Future _getPath(String type, bool multipleSelection) async { diff --git a/pubspec.yaml b/pubspec.yaml index 5a7956f..5689b5b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +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.1 +version: 1.3.2 dependencies: