Skip to content

Commit f55d455

Browse files
[image_picker] Update to 1.0 (flutter#4285)
The plugin now covers all of our supported platforms, most highly-requested features have been addressed, and the API has been stable for quite some time (in that no breaking changes have been required). Given that, a 1.0 version number reflects the current state of the package than a 0.x version. As part of the breaking change, the `get*` methods that were deprecated several years ago have now been removed.
1 parent 48232e8 commit f55d455

File tree

5 files changed

+24
-438
lines changed

5 files changed

+24
-438
lines changed

packages/image_picker/image_picker/CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
## 1.0.0
2+
3+
* **BREAKING CHANGE**: Removes the deprecated `get*` methods. Clients who have
4+
not already done so will need to migrate to the `pick*` versions that use
5+
`XFile` rather than `PickedFile` for return values.
6+
* As this is the only change, we encourage authors of published packages
7+
that depend on `image_picker` to consider using a constraint of
8+
`'>=0.8.9 <2.0.0'` rather than `^1.0.0` when updating dependencies, to
9+
avoid conflicts with packages that have not yet updated.
10+
111
## 0.8.9
212

3-
* Adds `getMedia` and `getMultipleMedia` methods.
13+
* Adds `pickMedia` and `pickMultipleMedia` methods.
414

515
## 0.8.8
616

packages/image_picker/image_picker/README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,13 @@ final XFile? media = await picker.pickMedia();
186186
final List<XFile> medias = await picker.pickMultipleMedia();
187187
```
188188

189-
## Migrating to 0.8.2+
189+
## Migrating to 1.0
190190

191-
Starting with version **0.8.2** of the image_picker plugin, new methods have
192-
been added for picking files that return `XFile` instances (from the
191+
Starting with version 0.8.2 of the image_picker plugin, new methods were
192+
added that return `XFile` instances (from the
193193
[cross_file](https://pub.dev/packages/cross_file) package) rather than the
194-
plugin's own `PickedFile` instances. While the previous methods still exist, it
195-
is already recommended to start migrating over to their new equivalents.
196-
Eventually, `PickedFile` and the methods that return instances of it will be
197-
deprecated and removed.
194+
plugin's own `PickedFile` instances. The previous methods were supported through
195+
0.8.9, and removed in 1.0.0.
198196

199197
#### Call the new methods
200198

packages/image_picker/image_picker/lib/image_picker.dart

Lines changed: 7 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -25,150 +25,10 @@ class ImagePicker {
2525
@visibleForTesting
2626
static ImagePickerPlatform get platform => ImagePickerPlatform.instance;
2727

28-
/// Returns a [PickedFile] object wrapping the image that was picked.
29-
///
30-
/// The returned [PickedFile] is intended to be used within a single app session. Do not save the file path and use it across sessions.
31-
///
32-
/// The `source` argument controls where the image comes from. This can
33-
/// be either [ImageSource.camera] or [ImageSource.gallery].
34-
///
35-
/// Where iOS supports HEIC images, Android 8 and below doesn't. Android 9 and above only support HEIC images if used
36-
/// in addition to a size modification, of which the usage is explained below.
37-
///
38-
/// If specified, the image will be at most `maxWidth` wide and
39-
/// `maxHeight` tall. Otherwise the image will be returned at it's
40-
/// original width and height.
41-
/// The `imageQuality` argument modifies the quality of the image, ranging from 0-100
42-
/// where 100 is the original/max quality. If `imageQuality` is null, the image with
43-
/// the original quality will be returned. Compression is only supported for certain
44-
/// image types such as JPEG and on Android PNG and WebP, too. If compression is not supported for the image that is picked,
45-
/// a warning message will be logged.
46-
///
47-
/// Use `preferredCameraDevice` to specify the camera to use when the `source` is [ImageSource.camera].
48-
/// The `preferredCameraDevice` is ignored when `source` is [ImageSource.gallery]. It is also ignored if the chosen camera is not supported on the device.
49-
/// Defaults to [CameraDevice.rear]. Note that Android has no documented parameter for an intent to specify if
50-
/// the front or rear camera should be opened, this function is not guaranteed
51-
/// to work on an Android device.
52-
///
53-
/// In Android, the MainActivity can be destroyed for various reasons. If that happens, the result will be lost
54-
/// in this call. You can then call [getLostData] when your app relaunches to retrieve the lost data.
55-
///
56-
/// See also [getMultiImage] to allow users to select multiple images at once.
57-
///
58-
/// The method could throw [PlatformException] if the app does not have permission to access
59-
/// the camera or photos gallery, no camera is available, plugin is already in use,
60-
/// temporary file could not be created (iOS only), plugin activity could not
61-
/// be allocated (Android only) or due to an unknown error.
62-
@Deprecated('Switch to using pickImage instead')
63-
Future<PickedFile?> getImage({
64-
required ImageSource source,
65-
double? maxWidth,
66-
double? maxHeight,
67-
int? imageQuality,
68-
CameraDevice preferredCameraDevice = CameraDevice.rear,
69-
}) {
70-
return platform.pickImage(
71-
source: source,
72-
maxWidth: maxWidth,
73-
maxHeight: maxHeight,
74-
imageQuality: imageQuality,
75-
preferredCameraDevice: preferredCameraDevice,
76-
);
77-
}
78-
79-
/// Returns a [List<PickedFile>] object wrapping the images that were picked.
80-
///
81-
/// The returned [List<PickedFile>] is intended to be used within a single app session. Do not save the file path and use it across sessions.
82-
///
83-
/// Where iOS supports HEIC images, Android 8 and below doesn't. Android 9 and above only support HEIC images if used
84-
/// in addition to a size modification, of which the usage is explained below.
85-
///
86-
/// This method is not supported in iOS versions lower than 14.
87-
///
88-
/// If specified, the images will be at most `maxWidth` wide and
89-
/// `maxHeight` tall. Otherwise the images will be returned at it's
90-
/// original width and height.
91-
/// The `imageQuality` argument modifies the quality of the images, ranging from 0-100
92-
/// where 100 is the original/max quality. If `imageQuality` is null, the images with
93-
/// the original quality will be returned. Compression is only supported for certain
94-
/// image types such as JPEG and on Android PNG and WebP, too. If compression is not supported for the image that is picked,
95-
/// a warning message will be logged.
96-
///
97-
/// The method could throw [PlatformException] if the app does not have permission to access
98-
/// the camera or photos gallery, no camera is available, plugin is already in use,
99-
/// temporary file could not be created (iOS only), plugin activity could not
100-
/// be allocated (Android only) or due to an unknown error.
101-
///
102-
/// See also [getImage] to allow users to only pick a single image.
103-
@Deprecated('Switch to using pickMultiImage instead')
104-
Future<List<PickedFile>?> getMultiImage({
105-
double? maxWidth,
106-
double? maxHeight,
107-
int? imageQuality,
108-
}) {
109-
return platform.pickMultiImage(
110-
maxWidth: maxWidth,
111-
maxHeight: maxHeight,
112-
imageQuality: imageQuality,
113-
);
114-
}
115-
116-
/// Returns a [PickedFile] object wrapping the video that was picked.
117-
///
118-
/// The returned [PickedFile] is intended to be used within a single app session. Do not save the file path and use it across sessions.
119-
///
120-
/// The [source] argument controls where the video comes from. This can
121-
/// be either [ImageSource.camera] or [ImageSource.gallery].
122-
///
123-
/// The [maxDuration] argument specifies the maximum duration of the captured video. If no [maxDuration] is specified,
124-
/// the maximum duration will be infinite.
125-
///
126-
/// Use `preferredCameraDevice` to specify the camera to use when the `source` is [ImageSource.camera].
127-
/// The `preferredCameraDevice` is ignored when `source` is [ImageSource.gallery]. It is also ignored if the chosen camera is not supported on the device.
128-
/// Defaults to [CameraDevice.rear].
129-
///
130-
/// In Android, the MainActivity can be destroyed for various reasons. If that happens, the result will be lost
131-
/// in this call. You can then call [getLostData] when your app relaunches to retrieve the lost data.
132-
///
133-
/// The method could throw [PlatformException] if the app does not have permission to access
134-
/// the camera or photos gallery, no camera is available, plugin is already in use,
135-
/// temporary file could not be created and video could not be cached (iOS only),
136-
/// plugin activity could not be allocated (Android only) or due to an unknown error.
137-
///
138-
@Deprecated('Switch to using pickVideo instead')
139-
Future<PickedFile?> getVideo({
140-
required ImageSource source,
141-
CameraDevice preferredCameraDevice = CameraDevice.rear,
142-
Duration? maxDuration,
143-
}) {
144-
return platform.pickVideo(
145-
source: source,
146-
preferredCameraDevice: preferredCameraDevice,
147-
maxDuration: maxDuration,
148-
);
149-
}
150-
151-
/// Retrieve the lost [PickedFile] when [selectImage] or [selectVideo] failed because the MainActivity is destroyed. (Android only)
152-
///
153-
/// Image or video can be lost if the MainActivity is destroyed. And there is no guarantee that the MainActivity is always alive.
154-
/// Call this method to retrieve the lost data and process the data according to your app's business logic.
155-
///
156-
/// Returns a [LostData] object if successfully retrieved the lost data. The [LostData] object can represent either a
157-
/// successful image/video selection, or a failure.
158-
///
159-
/// Calling this on a non-Android platform will throw [UnimplementedError] exception.
160-
///
161-
/// See also:
162-
/// * [LostData], for what's included in the response.
163-
/// * [Android Activity Lifecycle](https://developer.android.com/reference/android/app/Activity.html), for more information on MainActivity destruction.
164-
@Deprecated('Switch to using retrieveLostData instead')
165-
Future<LostData> getLostData() {
166-
return platform.retrieveLostData();
167-
}
168-
16928
/// Returns an [XFile] object wrapping the image that was picked.
17029
///
171-
/// The returned [XFile] is intended to be used within a single app session. Do not save the file path and use it across sessions.
30+
/// The returned [XFile] is intended to be used within a single app session.
31+
/// Do not save the file path and use it across sessions.
17232
///
17333
/// The `source` argument controls where the image comes from. This can
17434
/// be either [ImageSource.camera] or [ImageSource.gallery].
@@ -234,7 +94,8 @@ class ImagePicker {
23494

23595
/// Returns a [List<XFile>] object wrapping the images that were picked.
23696
///
237-
/// The returned [List<XFile>] is intended to be used within a single app session. Do not save the file path and use it across sessions.
97+
/// The returned [List<XFile>] is intended to be used within a single app session.
98+
/// Do not save the file path and use it across sessions.
23899
///
239100
/// Where iOS supports HEIC images, Android 8 and below doesn't. Android 9 and above only support HEIC images if used
240101
/// in addition to a size modification, of which the usage is explained below.
@@ -284,7 +145,8 @@ class ImagePicker {
284145
}
285146

286147
/// Returns an [XFile] of the image or video that was picked.
287-
/// The image or videos can only come from the gallery.
148+
///
149+
/// The image or video can only come from the gallery.
288150
///
289151
/// The returned [XFile] is intended to be used within a single app session.
290152
/// Do not save the file path and use it across sessions.
@@ -339,6 +201,7 @@ class ImagePicker {
339201
}
340202

341203
/// Returns a [List<XFile>] with the images and/or videos that were picked.
204+
///
342205
/// The images and videos come from the gallery.
343206
///
344207
/// The returned [List<XFile>] is intended to be used within a single app session.

packages/image_picker/image_picker/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for selecting images from the Android and iOS image
33
library, and taking new pictures with the camera.
44
repository: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
6-
version: 0.8.9
6+
version: 1.0.0
77

88
environment:
99
sdk: ">=2.18.0 <4.0.0"

0 commit comments

Comments
 (0)