Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[image_picker] add forceFullMetadata to interface #4288

Merged
merged 1 commit into from
Sep 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class ImagePickerPlugin extends ImagePickerPlatform {
double? maxWidth,
double? maxHeight,
int? imageQuality,
bool forceFullMetadata = true,
CameraDevice preferredCameraDevice = CameraDevice.rear,
}) {
String? capture = computeCaptureAttribute(source, preferredCameraDevice);
Expand Down Expand Up @@ -115,6 +116,7 @@ class ImagePickerPlugin extends ImagePickerPlatform {
double? maxWidth,
double? maxHeight,
int? imageQuality,
bool forceFullMetadata = true,
CameraDevice preferredCameraDevice = CameraDevice.rear,
}) async {
String? capture = computeCaptureAttribute(source, preferredCameraDevice);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 2.4.0

* Add `forceFullMetadata` option to `pickImage`.
* To keep this non-breaking `forceFullMetadata` defaults to `true`, so the plugin tries
to get the full image metadata which may require extra permission requests on certain platforms.
* If `forceFullMetadata` is set to `false`, the plugin fetches the image in a way that reduces
permission requests from the platform (e.g on iOS the plugin won’t ask for the `NSPhotoLibraryUsageDescription` permission).

## 2.3.0

* Updated `LostDataResponse` to include a `files` property, in case more than one file was recovered.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ class MethodChannelImagePicker extends ImagePickerPlatform {
double? maxWidth,
double? maxHeight,
int? imageQuality,
bool forceFullMetadata = true,
CameraDevice preferredCameraDevice = CameraDevice.rear,
}) async {
String? path = await _getImagePath(
source: source,
maxWidth: maxWidth,
maxHeight: maxHeight,
imageQuality: imageQuality,
forceFullMetadata: forceFullMetadata,
preferredCameraDevice: preferredCameraDevice,
);
return path != null ? PickedFile(path) : null;
Expand Down Expand Up @@ -85,6 +87,7 @@ class MethodChannelImagePicker extends ImagePickerPlatform {
double? maxWidth,
double? maxHeight,
int? imageQuality,
bool forceFullMetadata = true,
CameraDevice preferredCameraDevice = CameraDevice.rear,
}) {
if (imageQuality != null && (imageQuality < 0 || imageQuality > 100)) {
Expand All @@ -107,6 +110,7 @@ class MethodChannelImagePicker extends ImagePickerPlatform {
'maxWidth': maxWidth,
'maxHeight': maxHeight,
'imageQuality': imageQuality,
'forceFullMetadata': forceFullMetadata,
'cameraDevice': preferredCameraDevice.index
},
);
Expand Down Expand Up @@ -183,13 +187,15 @@ class MethodChannelImagePicker extends ImagePickerPlatform {
double? maxWidth,
double? maxHeight,
int? imageQuality,
bool forceFullMetadata = true,
CameraDevice preferredCameraDevice = CameraDevice.rear,
}) async {
String? path = await _getImagePath(
source: source,
maxWidth: maxWidth,
maxHeight: maxHeight,
imageQuality: imageQuality,
forceFullMetadata: forceFullMetadata,
preferredCameraDevice: preferredCameraDevice,
);
return path != null ? XFile(path) : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ abstract class ImagePickerPlatform extends PlatformInterface {
/// image types such as JPEG. If compression is not supported for the image that is picked,
/// a warning message will be logged.
///
/// `forceFullMetadata` defaults to `true`, so the plugin tries to get the full image metadata which may require
/// extra permission requests on certain platforms.
/// If `forceFullMetadata` is set to `false`, the plugin fetches the image in a way that reduces permission requests
/// from the platform (e.g. on iOS the plugin won’t ask for the `NSPhotoLibraryUsageDescription` permission).
///
/// Use `preferredCameraDevice` to specify the camera to use when the `source` is [ImageSource.camera].
/// The `preferredCameraDevice` is ignored when `source` is [ImageSource.gallery]. It is also ignored if the chosen camera is not supported on the device.
/// Defaults to [CameraDevice.rear]. Note that Android has no documented parameter for an intent to specify if
Expand All @@ -73,6 +78,7 @@ abstract class ImagePickerPlatform extends PlatformInterface {
double? maxWidth,
double? maxHeight,
int? imageQuality,
bool forceFullMetadata = true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change. This needs to be reverted, as this version is broken (and we need to figure out how to make sure this kind of thing doesn't pass CI in the future).

CameraDevice preferredCameraDevice = CameraDevice.rear,
}) {
throw UnimplementedError('pickImage() has not been implemented.');
Expand Down Expand Up @@ -164,6 +170,11 @@ abstract class ImagePickerPlatform extends PlatformInterface {
/// image types such as JPEG. If compression is not supported for the image that is picked,
/// a warning message will be logged.
///
/// `forceFullMetadata` defaults to `true`, so the plugin tries to get the full image metadata which may require
/// extra permission requests on certain platforms.
/// If `forceFullMetadata` is set to `false`, the plugin fetches the image in a way that reduces permission requests
/// from the platform (e.g. on iOS the plugin won’t ask for the `NSPhotoLibraryUsageDescription` permission).
///
/// Use `preferredCameraDevice` to specify the camera to use when the `source` is [ImageSource.camera].
/// The `preferredCameraDevice` is ignored when `source` is [ImageSource.gallery]. It is also ignored if the chosen camera is not supported on the device.
/// Defaults to [CameraDevice.rear]. Note that Android has no documented parameter for an intent to specify if
Expand All @@ -179,6 +190,7 @@ abstract class ImagePickerPlatform extends PlatformInterface {
double? maxWidth,
double? maxHeight,
int? imageQuality,
bool forceFullMetadata = true,
CameraDevice preferredCameraDevice = CameraDevice.rear,
}) {
throw UnimplementedError('getImage() has not been implemented.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/master/packages/image_picker
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 2.3.0
version: 2.4.0

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ void main() {
'maxWidth': null,
'maxHeight': null,
'imageQuality': null,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
isMethodCall('pickImage', arguments: <String, dynamic>{
'source': 1,
'maxWidth': null,
'maxHeight': null,
'imageQuality': null,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
],
);
Expand Down Expand Up @@ -93,49 +95,56 @@ void main() {
'maxWidth': null,
'maxHeight': null,
'imageQuality': null,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
isMethodCall('pickImage', arguments: <String, dynamic>{
'source': 0,
'maxWidth': 10.0,
'maxHeight': null,
'imageQuality': null,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
isMethodCall('pickImage', arguments: <String, dynamic>{
'source': 0,
'maxWidth': null,
'maxHeight': 10.0,
'imageQuality': null,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
isMethodCall('pickImage', arguments: <String, dynamic>{
'source': 0,
'maxWidth': 10.0,
'maxHeight': 20.0,
'imageQuality': null,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
isMethodCall('pickImage', arguments: <String, dynamic>{
'source': 0,
'maxWidth': 10.0,
'maxHeight': null,
'imageQuality': 70,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
isMethodCall('pickImage', arguments: <String, dynamic>{
'source': 0,
'maxWidth': null,
'maxHeight': 10.0,
'imageQuality': 70,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
isMethodCall('pickImage', arguments: <String, dynamic>{
'source': 0,
'maxWidth': 10.0,
'maxHeight': 20.0,
'imageQuality': 70,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
],
);
Expand Down Expand Up @@ -196,6 +205,7 @@ void main() {
'maxHeight': null,
'imageQuality': null,
'cameraDevice': 0,
'forceFullMetadata': true,
}),
],
);
Expand All @@ -215,6 +225,7 @@ void main() {
'maxHeight': null,
'imageQuality': null,
'cameraDevice': 1,
'forceFullMetadata': true,
}),
],
);
Expand Down Expand Up @@ -509,14 +520,16 @@ void main() {
'maxWidth': null,
'maxHeight': null,
'imageQuality': null,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
isMethodCall('pickImage', arguments: <String, dynamic>{
'source': 1,
'maxWidth': null,
'maxHeight': null,
'imageQuality': null,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
],
);
Expand Down Expand Up @@ -562,49 +575,56 @@ void main() {
'maxWidth': null,
'maxHeight': null,
'imageQuality': null,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
isMethodCall('pickImage', arguments: <String, dynamic>{
'source': 0,
'maxWidth': 10.0,
'maxHeight': null,
'imageQuality': null,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
isMethodCall('pickImage', arguments: <String, dynamic>{
'source': 0,
'maxWidth': null,
'maxHeight': 10.0,
'imageQuality': null,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
isMethodCall('pickImage', arguments: <String, dynamic>{
'source': 0,
'maxWidth': 10.0,
'maxHeight': 20.0,
'imageQuality': null,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
isMethodCall('pickImage', arguments: <String, dynamic>{
'source': 0,
'maxWidth': 10.0,
'maxHeight': null,
'imageQuality': 70,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
isMethodCall('pickImage', arguments: <String, dynamic>{
'source': 0,
'maxWidth': null,
'maxHeight': 10.0,
'imageQuality': 70,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
isMethodCall('pickImage', arguments: <String, dynamic>{
'source': 0,
'maxWidth': 10.0,
'maxHeight': 20.0,
'imageQuality': 70,
'cameraDevice': 0
'cameraDevice': 0,
'forceFullMetadata': true,
}),
],
);
Expand Down Expand Up @@ -664,6 +684,7 @@ void main() {
'maxHeight': null,
'imageQuality': null,
'cameraDevice': 0,
'forceFullMetadata': true,
}),
],
);
Expand All @@ -683,6 +704,7 @@ void main() {
'maxHeight': null,
'imageQuality': null,
'cameraDevice': 1,
'forceFullMetadata': true,
}),
],
);
Expand Down