This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[image_picker] add requestFullMetadata for iOS (optional permissions) - platform interface #5603
Merged
fluttergithubbot
merged 9 commits into
flutter:main
from
PiotrMitkowski:ios-optional-permissions-platform
May 11, 2022
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3335935
Implemented platform changes for optional gallery permissions
PiotrMitkowski 93874c0
Added PR remarks for documentation in platform interface
PiotrMitkowski 2983b84
PR remarks
PiotrMitkowski fdeb8bf
Merge branch 'main' of github.com:flutter/plugins into ios-optional-p…
PiotrMitkowski 577f6bf
Update packages/image_picker/image_picker_platform_interface/CHANGELO…
PiotrMitkowski 1e94e07
Update packages/image_picker/image_picker_platform_interface/lib/src/…
PiotrMitkowski ca7e4b4
PR remarks
PiotrMitkowski 816b59b
PR remarks
PiotrMitkowski ffb2d79
Merge branch 'main' of github.com:flutter/plugins into ios-optional-p…
PiotrMitkowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
packages/image_picker/image_picker_platform_interface/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,6 +146,8 @@ abstract class ImagePickerPlatform extends PlatformInterface { | |
throw UnimplementedError('retrieveLostData() has not been implemented.'); | ||
} | ||
|
||
/// This method is deprecated in favor of [getImageFromSource] and will be removed in a future update. | ||
/// | ||
/// Returns an [XFile] with the image that was picked. | ||
/// | ||
/// The `source` argument controls where the image comes from. This can | ||
|
@@ -251,4 +253,32 @@ abstract class ImagePickerPlatform extends PlatformInterface { | |
Future<LostDataResponse> getLostData() { | ||
throw UnimplementedError('getLostData() has not been implemented.'); | ||
} | ||
|
||
/// Returns an [XFile] with the image that was picked. | ||
/// | ||
/// The `source` argument controls where the image comes from. This can | ||
/// be either [ImageSource.camera] or [ImageSource.gallery]. | ||
/// | ||
/// The `options` argument controls additional settings that can be used when picking an image. See [ImagePickerOptions] | ||
/// for more details. | ||
/// | ||
/// Where iOS supports HEIC images, Android 8 and below doesn't. Android 9 and above only support HEIC images if used | ||
/// in addition to a size modification, of which the usage is explained in [ImagePickerOptions]. | ||
/// | ||
/// In Android, the MainActivity can be destroyed for various reasons. If that happens, the result will be lost | ||
/// 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. | ||
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. Please wrap all the lines in this comment block to 80 characters. |
||
Future<XFile?> getImageFromSource({ | ||
required ImageSource source, | ||
ImagePickerOptions options = const ImagePickerOptions(), | ||
}) { | ||
return getImage( | ||
source: source, | ||
maxHeight: options.maxHeight, | ||
maxWidth: options.maxWidth, | ||
imageQuality: options.imageQuality, | ||
preferredCameraDevice: options.preferredCameraDevice, | ||
); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...ages/image_picker/image_picker_platform_interface/lib/src/types/image_picker_options.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// 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. | ||
|
||
import 'package:image_picker_platform_interface/src/types/types.dart'; | ||
|
||
/// Specifies options for picking a single image from the device's camera or gallery. | ||
class ImagePickerOptions { | ||
/// Creates an instance with the given [maxHeight], [maxWidth], [imageQuality], | ||
/// [referredCameraDevice] and [requestFullMetadata]. | ||
const ImagePickerOptions({ | ||
this.maxHeight, | ||
this.maxWidth, | ||
this.imageQuality, | ||
this.preferredCameraDevice = CameraDevice.rear, | ||
this.requestFullMetadata = true, | ||
}); | ||
|
||
/// The maximum width of the image, in pixels. If null, the image will only | ||
/// be resized if maxHeight is specified. | ||
PiotrMitkowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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. | ||
/// | ||
/// If null, the image will be returned with the original 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. | ||
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. Nit: this is two unrelated things, so should be their own paragraphs:
|
||
final int? imageQuality; | ||
|
||
/// Used to specify the camera to use when the `source` is [ImageSource.camera]. | ||
/// | ||
/// Ignored if the source is not [ImageSource.camera], or the chosen camera is not | ||
/// supported on the device. Defaults to [CameraDevice.rear]. | ||
final CameraDevice preferredCameraDevice; | ||
|
||
/// 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; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.