You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[image_picker] Mention launchMode: singleInstance in README (#3759)
Users of the image picker are reporting issues for Android when setting the `launchMode` of the application activity to `singleInstance`. Namely, the image picker will always return `RESULT_CANCELED`. After investigation, it turned out that this problem is inherent by the way Android handles activities with this launch mode: `singleInstance` instructs the framework to open new activities in a new task. As activities cannot communicate between tasks, the image picker activity is unable to relay back the result to the calling activity.
This PR updates the README to mention this behavior and provide a workaround.
Closes [76856](flutter/flutter#76856).
Copy file name to clipboardExpand all lines: packages/image_picker/image_picker/README.md
+80-43Lines changed: 80 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,54 +12,48 @@ and taking new pictures with the camera.
12
12
13
13
## Installation
14
14
15
-
First, add `image_picker` as a [dependency in your pubspec.yaml file](https://flutter.dev/docs/development/platform-integration/platform-channels).
15
+
First, add `image_picker` as a
16
+
[dependency in your pubspec.yaml file](https://flutter.dev/docs/development/platform-integration/platform-channels).
16
17
17
18
### iOS
18
19
19
-
Starting with version **0.8.1** the iOS implementation uses PHPicker to pick (multiple) images on iOS 14 or higher.
20
-
As a result of implementing PHPicker it becomes impossible to pick HEIC images on the iOS simulator in iOS 14+. This is a known issue. Please test this on a real device, or test with non-HEIC images until Apple solves this issue. [63426347 - Apple known issue](https://www.google.com/search?q=63426347+apple&sxsrf=ALeKk01YnTMid5S0PYvhL8GbgXJ40ZS[…]t=gws-wiz&ved=0ahUKEwjKh8XH_5HwAhWL_rsIHUmHDN8Q4dUDCA8&uact=5)
21
-
22
-
Add the following keys to your _Info.plist_ file, located in `<project root>/ios/Runner/Info.plist`:
23
-
24
-
*`NSPhotoLibraryUsageDescription` - describe why your app needs permission for the photo library. This is called _Privacy - Photo Library Usage Description_ in the visual editor.
25
-
* This permission will not be requested if you always pass `false` for `requestFullMetadata`, but App Store policy requires including the plist entry.
26
-
*`NSCameraUsageDescription` - describe why your app needs access to the camera. This is called _Privacy - Camera Usage Description_ in the visual editor.
27
-
*`NSMicrophoneUsageDescription` - describe why your app needs access to the microphone, if you intend to record videos. This is called _Privacy - Microphone Usage Description_ in the visual editor.
20
+
Starting with version **0.8.1** the iOS implementation uses PHPicker to pick
21
+
(multiple) images on iOS 14 or higher.
22
+
As a result of implementing PHPicker it becomes impossible to pick HEIC images
23
+
on the iOS simulator in iOS 14+. This is a known issue. Please test this on a
24
+
real device, or test with non-HEIC images until Apple solves this issue.
25
+
[63426347 - Apple known issue](https://www.google.com/search?q=63426347+apple&sxsrf=ALeKk01YnTMid5S0PYvhL8GbgXJ40ZS[…]t=gws-wiz&ved=0ahUKEwjKh8XH_5HwAhWL_rsIHUmHDN8Q4dUDCA8&uact=5)
26
+
27
+
Add the following keys to your _Info.plist_ file, located in
28
+
`<project root>/ios/Runner/Info.plist`:
29
+
30
+
*`NSPhotoLibraryUsageDescription` - describe why your app needs permission for
31
+
the photo library. This is called _Privacy - Photo Library Usage Description_ in
32
+
the visual editor.
33
+
* This permission will not be requested if you always pass `false` for
34
+
`requestFullMetadata`, but App Store policy requires including the plist
35
+
entry.
36
+
*`NSCameraUsageDescription` - describe why your app needs access to the camera.
37
+
This is called _Privacy - Camera Usage Description_ in the visual editor.
38
+
*`NSMicrophoneUsageDescription` - describe why your app needs access to the
39
+
microphone, if you intend to record videos. This is called
40
+
_Privacy - Microphone Usage Description_ in the visual editor.
28
41
29
42
### Android
30
43
31
-
Starting with version **0.8.1** the Android implementation support to pick (multiple) images on Android 4.3 or higher.
44
+
Starting with version **0.8.1** the Android implementation support to pick
45
+
(multiple) images on Android 4.3 or higher.
32
46
33
-
No configuration required - the plugin should work out of the box. It is
34
-
however highly recommended to prepare for Android killing the application when
35
-
low on memory. How to prepare for this is discussed in the [Handling
36
-
MainActivity destruction on Android](#handling-mainactivity-destruction-on-android)
47
+
No configuration required - the plugin should work out of the box. It is however
48
+
highly recommended to prepare for Android killing the application when low on memory. How to prepare for this is discussed in the
49
+
[Handling MainActivity destruction on Android](#handling-mainactivity-destruction-on-android)
37
50
section.
38
51
39
-
It is no longer required to add `android:requestLegacyExternalStorage="true"` as an attribute to the `<application>` tag in AndroidManifest.xml, as `image_picker` has been updated to make use of scoped storage.
40
-
41
-
**Note:** Images and videos picked using the camera are saved to your application's local cache, and should therefore be expected to only be around temporarily.
42
-
If you require your picked image to be stored permanently, it is your responsibility to move it to a more permanent location.
43
-
44
-
### Example
45
-
46
-
<?code-excerpt "readme_excerpts.dart (Pick)"?>
47
-
```dart
48
-
final ImagePicker picker = ImagePicker();
49
-
// Pick an image.
50
-
final XFile? image = await picker.pickImage(source: ImageSource.gallery);
51
-
// Capture a photo.
52
-
final XFile? photo = await picker.pickImage(source: ImageSource.camera);
final XFile? cameraVideo = await picker.pickVideo(source: ImageSource.camera);
126
+
// Pick multiple images.
127
+
final List<XFile> images = await picker.pickMultiImage();
128
+
```
129
+
100
130
## Migrating to 0.8.2+
101
131
102
-
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.
132
+
Starting with version **0.8.2** of the image_picker plugin, new methods have
133
+
been added for picking files that return `XFile` instances (from the
134
+
[cross_file](https://pub.dev/packages/cross_file) package) rather than the
135
+
plugin's own `PickedFile` instances. While the previous methods still exist, it
136
+
is already recommended to start migrating over to their new equivalents.
137
+
Eventually, `PickedFile` and the methods that return instances of it will be
138
+
deprecated and removed.
103
139
104
140
#### Call the new methods
105
141
@@ -111,3 +147,4 @@ Starting with version **0.8.2** of the image_picker plugin, new methods have bee
0 commit comments