-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[image_picker] add requestFullMetadata for iOS (optional permissions) - platform interface changes for multi image picking #5914
Changes from 3 commits
a4e4612
b3a68bb
040609f
b4cb48d
f3d851f
527ec7c
6f015f8
d745335
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import 'dart:async'; | |
|
||
import 'package:cross_file/cross_file.dart'; | ||
import 'package:image_picker_platform_interface/src/method_channel/method_channel_image_picker.dart'; | ||
import 'package:image_picker_platform_interface/src/types/multi_image_picker_options.dart'; | ||
import 'package:image_picker_platform_interface/src/types/types.dart'; | ||
import 'package:plugin_platform_interface/plugin_platform_interface.dart'; | ||
|
||
|
@@ -186,6 +187,8 @@ abstract class ImagePickerPlatform extends PlatformInterface { | |
throw UnimplementedError('getImage() has not been implemented.'); | ||
} | ||
|
||
/// This method is deprecated in favor of [getMultiImageWithOptions] and will be removed in a future update. | ||
cyanglaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// | ||
/// Returns a [List<XFile>] with the images that were picked. | ||
/// | ||
/// The images come from the [ImageSource.gallery]. | ||
|
@@ -283,4 +286,22 @@ abstract class ImagePickerPlatform extends PlatformInterface { | |
preferredCameraDevice: options.preferredCameraDevice, | ||
); | ||
} | ||
|
||
/// Returns a [List<XFile>] with the images that were picked. | ||
/// | ||
/// The images come from the [ImageSource.gallery]. | ||
/// | ||
/// The `options` argument controls additional settings that can be used when | ||
/// picking an image. See [MultiImagePickerOptions] for more details. | ||
/// | ||
/// If no images were picked, the return value is null. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should make the return value non-nullable, and return empty for no images, so that we don't have two ways of expressing no files. |
||
Future<List<XFile>?> getMultiImageWithOptions({ | ||
MultiImagePickerOptions options = const MultiImagePickerOptions(), | ||
}) { | ||
return getMultiImage( | ||
maxWidth: options.maxWidth, | ||
maxHeight: options.maxHeight, | ||
imageQuality: options.imageQuality, | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
/// Specifies options for picking multiple images from the device's gallery. | ||
class MultiImagePickerOptions { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally we would share this with |
||
/// Creates an instance with the given [maxHeight], [maxWidth], [imageQuality] | ||
/// and [requestFullMetadata]. | ||
const MultiImagePickerOptions({ | ||
this.maxHeight, | ||
this.maxWidth, | ||
this.imageQuality, | ||
this.requestFullMetadata = true, | ||
}); | ||
|
||
/// The maximum width of the image, in pixels. | ||
/// | ||
/// If null, the image will only be resized if [maxHeight] is specified. | ||
final double? maxWidth; | ||
|
||
/// The maximum height of the image, in pixels. | ||
/// | ||
/// If null, the image will only be resized if [maxWidth] is specified. | ||
final double? maxHeight; | ||
|
||
/// Modifies the quality of the image, ranging from 0-100 where 100 is the | ||
/// original/max quality. | ||
/// | ||
/// Compression is only supported for certain image types such as JPEG. If | ||
/// compression is not supported for the image that is picked, a warning | ||
/// message will be logged. | ||
/// | ||
/// If null, the image will be returned with the original quality. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment is stale. |
||
final int? imageQuality; | ||
cyanglaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// If true, requests full image metadata, which may require extra permissions | ||
/// on some platforms, (e.g., NSPhotoLibraryUsageDescription on iOS). | ||
// | ||
// Defaults to true. | ||
final bool requestFullMetadata; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a space inbetween