From db2f8fce18fd98e55d97e57d248a2d9c696b1374 Mon Sep 17 00:00:00 2001 From: reez12g Date: Sat, 11 Sep 2021 18:53:11 +0900 Subject: [PATCH 1/2] [image_picker] Update README for image_picker's retrieveLostData() to support multiple files --- .../image_picker/image_picker/CHANGELOG.md | 4 ++++ packages/image_picker/image_picker/README.md | 19 ++++++++++--------- .../image_picker/image_picker/pubspec.yaml | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/image_picker/image_picker/CHANGELOG.md b/packages/image_picker/image_picker/CHANGELOG.md index 5dc260993773..de815b1ff302 100644 --- a/packages/image_picker/image_picker/CHANGELOG.md +++ b/packages/image_picker/image_picker/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.8.4+1 + +* Fix README Example for `ImagePickerCache` to cache multiple files. + ## 0.8.4 * Update `ImagePickerCache` to cache multiple files. diff --git a/packages/image_picker/image_picker/README.md b/packages/image_picker/image_picker/README.md index 7499c356f3aa..2a884b8e0837 100755 --- a/packages/image_picker/image_picker/README.md +++ b/packages/image_picker/image_picker/README.md @@ -63,13 +63,16 @@ Future getLostData() async { return; } if (response.file != null) { - setState(() { - if (response.type == RetrieveType.video) { - _handleVideo(response.file); - } else { - _handleImage(response.file); - } - }); + if (response.files.length >= 2 ) { + _imageFileList = response.files + } else { + setState(() { + if (response.type == RetrieveType.video) { + _handleVideo(response.file); + } else { + _handleImage(response.file); + } + }}); } else { _handleError(response.exception); } @@ -78,8 +81,6 @@ Future getLostData() async { There's no way to detect when this happens, so calling this method at the right place is essential. We recommend to wire this into some kind of start up check. Please refer to the example app to see how we used it. -On Android, `retrieveLostData` will only get the last picked image when picking multiple images, see: [#84634](https://github.com/flutter/flutter/issues/84634). - ## Migrating to 0.8.2+ Starting with version **0.8.2** of the image_picker plugin, new methods have been added for picking files that return `XFile` instances (from the [cross_file](https://pub.dev/packages/cross_file) package) rather than the plugin's own `PickedFile` instances. While the previous methods still exist, it is already recommended to start migrating over to their new equivalents. Eventually, `PickedFile` and the methods that return instances of it will be deprecated and removed. diff --git a/packages/image_picker/image_picker/pubspec.yaml b/packages/image_picker/image_picker/pubspec.yaml index 3bbcfe99882e..fca821be2d5f 100755 --- a/packages/image_picker/image_picker/pubspec.yaml +++ b/packages/image_picker/image_picker/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for selecting images from the Android and iOS image library, and taking new pictures with the camera. repository: https://github.com/flutter/plugins/tree/master/packages/image_picker/image_picker issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22 -version: 0.8.4 +version: 0.8.4+1 environment: sdk: ">=2.12.0 <3.0.0" From b1a2bd7dbd0e422fee4880f31032cb6a0ca24cea Mon Sep 17 00:00:00 2001 From: reez12g Date: Wed, 15 Sep 2021 16:12:00 +0900 Subject: [PATCH 2/2] [image_picker] Change image_picker's retrieveLostData() example to a simple one --- packages/image_picker/image_picker/README.md | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/packages/image_picker/image_picker/README.md b/packages/image_picker/image_picker/README.md index 2a884b8e0837..fc4813d1cee5 100755 --- a/packages/image_picker/image_picker/README.md +++ b/packages/image_picker/image_picker/README.md @@ -62,17 +62,10 @@ Future getLostData() async { if (response.isEmpty) { return; } - if (response.file != null) { - if (response.files.length >= 2 ) { - _imageFileList = response.files - } else { - setState(() { - if (response.type == RetrieveType.video) { - _handleVideo(response.file); - } else { - _handleImage(response.file); - } - }}); + if (response.files != null) { + for(final XFile file in response.files) { + _handleFile(file); + } } else { _handleError(response.exception); }