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

Commit 65e9045

Browse files
committed
change iosPhaAsset to forceFullMetaData
1 parent aee0d94 commit 65e9045

File tree

7 files changed

+41
-35
lines changed

7 files changed

+41
-35
lines changed

packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
7676
_arguments = call.arguments;
7777

7878
int imageSource = [[_arguments objectForKey:@"source"] intValue];
79-
BOOL usePhaAsset = [[_arguments objectForKey:@"iosPhaAsset"] boolValue];
79+
BOOL usePhaAsset = [[_arguments objectForKey:@"forceFullMetaData"] boolValue];
8080

8181
switch (imageSource) {
8282
case SOURCE_CAMERA: {
@@ -113,7 +113,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
113113
_arguments = call.arguments;
114114

115115
int imageSource = [[_arguments objectForKey:@"source"] intValue];
116-
BOOL usePhaAsset = [[_arguments objectForKey:@"iosPhaAsset"] boolValue];
116+
BOOL usePhaAsset = [[_arguments objectForKey:@"forceFullMetaData"] boolValue];
117117
if ([[_arguments objectForKey:@"maxDuration"] isKindOfClass:[NSNumber class]]) {
118118
NSTimeInterval max = [[_arguments objectForKey:@"maxDuration"] doubleValue];
119119
_imagePickerController.videoMaximumDuration = max;
@@ -309,7 +309,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker
309309
NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"];
310310
NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"];
311311
NSNumber *imageQuality = [_arguments objectForKey:@"imageQuality"];
312-
BOOL usePhaAsset = [[_arguments objectForKey:@"iosPhaAsset"] boolValue];
312+
BOOL usePhaAsset = [[_arguments objectForKey:@"forceFullMetaData"] boolValue];
313313

314314
if (![imageQuality isKindOfClass:[NSNumber class]]) {
315315
imageQuality = @1;

packages/image_picker/image_picker/lib/image_picker.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ class ImagePicker {
4646
/// image types such as JPEG and on Android PNG and WebP, too. If compression is not supported for the image that is picked,
4747
/// a warning message will be logged.
4848
///
49-
/// Set `iosPhaAsset` to `false` to disable `PHAAsset` and related permissions requirements on iOS.
49+
/// `forceFullMetaData` defaults to `true`, so the plugin tries to get the full image metadata which may require
50+
/// extra permission requests on certain platforms.
51+
/// If `forceFullMetaData` is set to `false`, the plugin fetches the image in a way that reduces permission requests
52+
/// from the platform (e.g on iOS the plugin won’t ask for the `NSPhotoLibraryUsageDescription` permission).
5053
///
5154
/// Use `preferredCameraDevice` to specify the camera to use when the `source` is [ImageSource.camera].
5255
/// The `preferredCameraDevice` is ignored when `source` is [ImageSource.gallery]. It is also ignored if the chosen camera is not supported on the device.
@@ -61,15 +64,15 @@ class ImagePicker {
6164
double? maxWidth,
6265
double? maxHeight,
6366
int? imageQuality,
64-
bool iosPhaAsset = true,
67+
bool forceFullMetaData = true,
6568
CameraDevice preferredCameraDevice = CameraDevice.rear,
6669
}) {
6770
return platform.pickImage(
6871
source: source,
6972
maxWidth: maxWidth,
7073
maxHeight: maxHeight,
7174
imageQuality: imageQuality,
72-
iosPhaAsset: iosPhaAsset,
75+
forceFullMetaData: forceFullMetaData,
7376
preferredCameraDevice: preferredCameraDevice,
7477
);
7578
}

packages/image_picker/image_picker/test/image_picker_test.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ void main() {
5252
'maxHeight': null,
5353
'imageQuality': null,
5454
'cameraDevice': 0,
55-
'iosPhaAsset': true,
55+
'forceFullMetaData': true,
5656
}),
5757
isMethodCall('pickImage', arguments: <String, dynamic>{
5858
'source': 1,
5959
'maxWidth': null,
6060
'maxHeight': null,
6161
'imageQuality': null,
6262
'cameraDevice': 0,
63-
'iosPhaAsset': true,
63+
'forceFullMetaData': true,
6464
}),
6565
],
6666
);
@@ -100,55 +100,55 @@ void main() {
100100
'maxHeight': null,
101101
'imageQuality': null,
102102
'cameraDevice': 0,
103-
'iosPhaAsset': true,
103+
'forceFullMetaData': true,
104104
}),
105105
isMethodCall('pickImage', arguments: <String, dynamic>{
106106
'source': 0,
107107
'maxWidth': 10.0,
108108
'maxHeight': null,
109109
'imageQuality': null,
110110
'cameraDevice': 0,
111-
'iosPhaAsset': true,
111+
'forceFullMetaData': true,
112112
}),
113113
isMethodCall('pickImage', arguments: <String, dynamic>{
114114
'source': 0,
115115
'maxWidth': null,
116116
'maxHeight': 10.0,
117117
'imageQuality': null,
118118
'cameraDevice': 0,
119-
'iosPhaAsset': true,
119+
'forceFullMetaData': true,
120120
}),
121121
isMethodCall('pickImage', arguments: <String, dynamic>{
122122
'source': 0,
123123
'maxWidth': 10.0,
124124
'maxHeight': 20.0,
125125
'imageQuality': null,
126126
'cameraDevice': 0,
127-
'iosPhaAsset': true,
127+
'forceFullMetaData': true,
128128
}),
129129
isMethodCall('pickImage', arguments: <String, dynamic>{
130130
'source': 0,
131131
'maxWidth': 10.0,
132132
'maxHeight': null,
133133
'imageQuality': 70,
134134
'cameraDevice': 0,
135-
'iosPhaAsset': true,
135+
'forceFullMetaData': true,
136136
}),
137137
isMethodCall('pickImage', arguments: <String, dynamic>{
138138
'source': 0,
139139
'maxWidth': null,
140140
'maxHeight': 10.0,
141141
'imageQuality': 70,
142142
'cameraDevice': 0,
143-
'iosPhaAsset': true,
143+
'forceFullMetaData': true,
144144
}),
145145
isMethodCall('pickImage', arguments: <String, dynamic>{
146146
'source': 0,
147147
'maxWidth': 10.0,
148148
'maxHeight': 20.0,
149149
'imageQuality': 70,
150150
'cameraDevice': 0,
151-
'iosPhaAsset': true,
151+
'forceFullMetaData': true,
152152
}),
153153
],
154154
);
@@ -185,7 +185,7 @@ void main() {
185185
'maxHeight': null,
186186
'imageQuality': null,
187187
'cameraDevice': 0,
188-
'iosPhaAsset': true,
188+
'forceFullMetaData': true,
189189
}),
190190
],
191191
);
@@ -205,7 +205,7 @@ void main() {
205205
'maxHeight': null,
206206
'imageQuality': null,
207207
'cameraDevice': 1,
208-
'iosPhaAsset': true,
208+
'forceFullMetaData': true,
209209
}),
210210
],
211211
);

packages/image_picker/image_picker_for_web/lib/image_picker_for_web.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ImagePickerPlugin extends ImagePickerPlatform {
3636
double maxWidth,
3737
double maxHeight,
3838
int imageQuality,
39-
bool iosPhaAsset = true,
39+
bool forceFullMetaData = true,
4040
CameraDevice preferredCameraDevice = CameraDevice.rear,
4141
}) {
4242
String capture = computeCaptureAttribute(source, preferredCameraDevice);

packages/image_picker/image_picker_platform_interface/lib/src/method_channel/method_channel_image_picker.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ class MethodChannelImagePicker extends ImagePickerPlatform {
2424
double? maxWidth,
2525
double? maxHeight,
2626
int? imageQuality,
27-
bool iosPhaAsset = true,
27+
bool forceFullMetaData = true,
2828
CameraDevice preferredCameraDevice = CameraDevice.rear,
2929
}) async {
3030
String? path = await _pickImagePath(
3131
source: source,
3232
maxWidth: maxWidth,
3333
maxHeight: maxHeight,
3434
imageQuality: imageQuality,
35-
iosPhaAsset: iosPhaAsset,
35+
forceFullMetaData: forceFullMetaData,
3636
preferredCameraDevice: preferredCameraDevice,
3737
);
3838
return path != null ? PickedFile(path) : null;
@@ -43,7 +43,7 @@ class MethodChannelImagePicker extends ImagePickerPlatform {
4343
double? maxWidth,
4444
double? maxHeight,
4545
int? imageQuality,
46-
bool iosPhaAsset = true,
46+
bool forceFullMetaData = true,
4747
CameraDevice preferredCameraDevice = CameraDevice.rear,
4848
}) {
4949
if (imageQuality != null && (imageQuality < 0 || imageQuality > 100)) {
@@ -66,7 +66,7 @@ class MethodChannelImagePicker extends ImagePickerPlatform {
6666
'maxWidth': maxWidth,
6767
'maxHeight': maxHeight,
6868
'imageQuality': imageQuality,
69-
'iosPhaAsset': iosPhaAsset,
69+
'forceFullMetaData': forceFullMetaData,
7070
'cameraDevice': preferredCameraDevice.index
7171
},
7272
);

packages/image_picker/image_picker_platform_interface/lib/src/platform_interface/image_picker_platform.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ abstract class ImagePickerPlatform extends PlatformInterface {
5858
/// image types such as JPEG. If compression is not supported for the image that is picked,
5959
/// an warning message will be logged.
6060
///
61-
/// Set `iosPhaAsset` to `false` to disable `PHAAsset` and related permissions requirements on iOS.
61+
/// `forceFullMetaData` defaults to `true`, so the plugin tries to get the full image metadata which may require
62+
/// extra permission requests on certain platforms.
63+
/// If `forceFullMetaData` is set to `false`, the plugin fetches the image in a way that reduces permission requests
64+
/// from the platform (e.g on iOS the plugin won’t ask for the `NSPhotoLibraryUsageDescription` permission).
6265
///
6366
/// Use `preferredCameraDevice` to specify the camera to use when the `source` is [ImageSource.camera].
6467
/// The `preferredCameraDevice` is ignored when `source` is [ImageSource.gallery]. It is also ignored if the chosen camera is not supported on the device.
@@ -75,7 +78,7 @@ abstract class ImagePickerPlatform extends PlatformInterface {
7578
double? maxWidth,
7679
double? maxHeight,
7780
int? imageQuality,
78-
bool iosPhaAsset = true,
81+
bool forceFullMetaData = true,
7982
CameraDevice preferredCameraDevice = CameraDevice.rear,
8083
}) {
8184
throw UnimplementedError('pickImage() has not been implemented.');

packages/image_picker/image_picker_platform_interface/test/new_method_channel_image_picker_test.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ void main() {
3939
'maxHeight': null,
4040
'imageQuality': null,
4141
'cameraDevice': 0,
42-
'iosPhaAsset': true,
42+
'forceFullMetaData': true,
4343
}),
4444
isMethodCall('pickImage', arguments: <String, dynamic>{
4545
'source': 1,
4646
'maxWidth': null,
4747
'maxHeight': null,
4848
'imageQuality': null,
4949
'cameraDevice': 0,
50-
'iosPhaAsset': true,
50+
'forceFullMetaData': true,
5151
}),
5252
],
5353
);
@@ -94,55 +94,55 @@ void main() {
9494
'maxHeight': null,
9595
'imageQuality': null,
9696
'cameraDevice': 0,
97-
'iosPhaAsset': true,
97+
'forceFullMetaData': true,
9898
}),
9999
isMethodCall('pickImage', arguments: <String, dynamic>{
100100
'source': 0,
101101
'maxWidth': 10.0,
102102
'maxHeight': null,
103103
'imageQuality': null,
104104
'cameraDevice': 0,
105-
'iosPhaAsset': true,
105+
'forceFullMetaData': true,
106106
}),
107107
isMethodCall('pickImage', arguments: <String, dynamic>{
108108
'source': 0,
109109
'maxWidth': null,
110110
'maxHeight': 10.0,
111111
'imageQuality': null,
112112
'cameraDevice': 0,
113-
'iosPhaAsset': true,
113+
'forceFullMetaData': true,
114114
}),
115115
isMethodCall('pickImage', arguments: <String, dynamic>{
116116
'source': 0,
117117
'maxWidth': 10.0,
118118
'maxHeight': 20.0,
119119
'imageQuality': null,
120120
'cameraDevice': 0,
121-
'iosPhaAsset': true,
121+
'forceFullMetaData': true,
122122
}),
123123
isMethodCall('pickImage', arguments: <String, dynamic>{
124124
'source': 0,
125125
'maxWidth': 10.0,
126126
'maxHeight': null,
127127
'imageQuality': 70,
128128
'cameraDevice': 0,
129-
'iosPhaAsset': true,
129+
'forceFullMetaData': true,
130130
}),
131131
isMethodCall('pickImage', arguments: <String, dynamic>{
132132
'source': 0,
133133
'maxWidth': null,
134134
'maxHeight': 10.0,
135135
'imageQuality': 70,
136136
'cameraDevice': 0,
137-
'iosPhaAsset': true,
137+
'forceFullMetaData': true,
138138
}),
139139
isMethodCall('pickImage', arguments: <String, dynamic>{
140140
'source': 0,
141141
'maxWidth': 10.0,
142142
'maxHeight': 20.0,
143143
'imageQuality': 70,
144144
'cameraDevice': 0,
145-
'iosPhaAsset': true,
145+
'forceFullMetaData': true,
146146
}),
147147
],
148148
);
@@ -180,7 +180,7 @@ void main() {
180180
'maxHeight': null,
181181
'imageQuality': null,
182182
'cameraDevice': 0,
183-
'iosPhaAsset': true,
183+
'forceFullMetaData': true,
184184
}),
185185
],
186186
);
@@ -200,7 +200,7 @@ void main() {
200200
'maxHeight': null,
201201
'imageQuality': null,
202202
'cameraDevice': 1,
203-
'iosPhaAsset': true,
203+
'forceFullMetaData': true,
204204
}),
205205
],
206206
);

0 commit comments

Comments
 (0)