-
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 6 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'; | ||
|
|
||
|
|
@@ -176,6 +177,7 @@ abstract class ImagePickerPlatform extends PlatformInterface { | |
| /// in this call. You can then call [getLostData] when your app relaunches to retrieve the lost data. | ||
| /// | ||
| /// If no images were picked, the return value is null. | ||
| @Deprecated('Use `getImageFromSource` instead.') | ||
| Future<XFile?> getImage({ | ||
| required ImageSource source, | ||
| double? maxWidth, | ||
|
|
@@ -186,6 +188,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. | ||
| /// | ||
| /// Returns a [List<XFile>] with the images that were picked. | ||
| /// | ||
| /// The images come from the [ImageSource.gallery]. | ||
|
|
@@ -204,6 +208,7 @@ abstract class ImagePickerPlatform extends PlatformInterface { | |
| /// a warning message will be logged. | ||
| /// | ||
| /// If no images were picked, the return value is null. | ||
| @Deprecated('Use `getMultiImageWithOptions` instead.') | ||
| Future<List<XFile>?> getMultiImage({ | ||
| double? maxWidth, | ||
| double? maxHeight, | ||
|
|
@@ -283,4 +288,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. | ||
|
||
| 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 { | ||
|
Contributor
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 = 100, | ||
| 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. | ||
|
||
| final int imageQuality; | ||
|
|
||
| /// 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; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.