[image_picker] Update iOS to Pigeon 13 (#5266)

This picks up some breaking changes in the Objective-C generator, most notably a switch from `NSNumber*` to `BOOL` for non-nullable boolean values, which avoids the class of problem noticed in https://github.com/flutter/packages/pull/5194
This commit is contained in:
stuartmorgan
2023-10-31 09:08:54 -07:00
committed by GitHub
parent c9fec61b6c
commit b195bde182
9 changed files with 172 additions and 95 deletions

View File

@ -1,3 +1,7 @@
## 0.8.8+4
* Updates to Pigeon 13.
## 0.8.8+3 ## 0.8.8+3
* Fixes a possible crash when calling a picker method while another is waiting on permissions. * Fixes a possible crash when calling a picker method while another is waiting on permissions.

View File

@ -56,7 +56,7 @@
camera:FLTSourceCameraRear] camera:FLTSourceCameraRear]
maxSize:[[FLTMaxSize alloc] init] maxSize:[[FLTMaxSize alloc] init]
quality:nil quality:nil
fullMetadata:@YES fullMetadata:YES
completion:^(NSString *_Nullable result, FlutterError *_Nullable error){ completion:^(NSString *_Nullable result, FlutterError *_Nullable error){
}]; }];
@ -89,7 +89,7 @@
camera:FLTSourceCameraFront] camera:FLTSourceCameraFront]
maxSize:[[FLTMaxSize alloc] init] maxSize:[[FLTMaxSize alloc] init]
quality:nil quality:nil
fullMetadata:@YES fullMetadata:YES
completion:^(NSString *_Nullable result, FlutterError *_Nullable error){ completion:^(NSString *_Nullable result, FlutterError *_Nullable error){
}]; }];
@ -174,7 +174,7 @@
[plugin pickMultiImageWithMaxSize:[FLTMaxSize makeWithWidth:@(100) height:@(200)] [plugin pickMultiImageWithMaxSize:[FLTMaxSize makeWithWidth:@(100) height:@(200)]
quality:@(50) quality:@(50)
fullMetadata:@YES fullMetadata:YES
completion:^(NSArray<NSString *> *_Nullable result, completion:^(NSArray<NSString *> *_Nullable result,
FlutterError *_Nullable error){ FlutterError *_Nullable error){
}]; }];
@ -197,8 +197,8 @@
FLTMediaSelectionOptions *mediaSelectionOptions = FLTMediaSelectionOptions *mediaSelectionOptions =
[FLTMediaSelectionOptions makeWithMaxSize:[FLTMaxSize makeWithWidth:@(100) height:@(200)] [FLTMediaSelectionOptions makeWithMaxSize:[FLTMaxSize makeWithWidth:@(100) height:@(200)]
imageQuality:@(50) imageQuality:@(50)
requestFullMetadata:@YES requestFullMetadata:YES
allowMultiple:@YES]; allowMultiple:YES];
[plugin pickMediaWithMediaSelectionOptions:mediaSelectionOptions [plugin pickMediaWithMediaSelectionOptions:mediaSelectionOptions
completion:^(NSArray<NSString *> *_Nullable result, completion:^(NSArray<NSString *> *_Nullable result,
@ -219,7 +219,7 @@
camera:FLTSourceCameraFront] camera:FLTSourceCameraFront]
maxSize:[[FLTMaxSize alloc] init] maxSize:[[FLTMaxSize alloc] init]
quality:nil quality:nil
fullMetadata:@NO fullMetadata:NO
completion:^(NSString *_Nullable result, FlutterError *_Nullable error){ completion:^(NSString *_Nullable result, FlutterError *_Nullable error){
}]; }];
@ -235,7 +235,7 @@
[plugin pickMultiImageWithMaxSize:[[FLTMaxSize alloc] init] [plugin pickMultiImageWithMaxSize:[[FLTMaxSize alloc] init]
quality:nil quality:nil
fullMetadata:@NO fullMetadata:NO
completion:^(NSArray<NSString *> *_Nullable result, completion:^(NSArray<NSString *> *_Nullable result,
FlutterError *_Nullable error){ FlutterError *_Nullable error){
}]; }];
@ -253,8 +253,8 @@
FLTMediaSelectionOptions *mediaSelectionOptions = FLTMediaSelectionOptions *mediaSelectionOptions =
[FLTMediaSelectionOptions makeWithMaxSize:[FLTMaxSize makeWithWidth:@(100) height:@(200)] [FLTMediaSelectionOptions makeWithMaxSize:[FLTMaxSize makeWithWidth:@(100) height:@(200)]
imageQuality:@(50) imageQuality:@(50)
requestFullMetadata:@YES requestFullMetadata:YES
allowMultiple:@YES]; allowMultiple:YES];
[plugin pickMediaWithMediaSelectionOptions:mediaSelectionOptions [plugin pickMediaWithMediaSelectionOptions:mediaSelectionOptions
@ -279,7 +279,7 @@
camera:FLTSourceCameraRear] camera:FLTSourceCameraRear]
maxSize:[[FLTMaxSize alloc] init] maxSize:[[FLTMaxSize alloc] init]
quality:nil quality:nil
fullMetadata:@YES fullMetadata:YES
completion:^(NSString *_Nullable result, FlutterError *_Nullable error){ completion:^(NSString *_Nullable result, FlutterError *_Nullable error){
}]; }];
@ -502,7 +502,7 @@
camera:FLTSourceCameraFront] camera:FLTSourceCameraFront]
maxSize:[[FLTMaxSize alloc] init] maxSize:[[FLTMaxSize alloc] init]
quality:nil quality:nil
fullMetadata:@YES fullMetadata:YES
completion:^(NSString *result, FlutterError *error){ completion:^(NSString *result, FlutterError *error){
}]; }];
OCMVerifyAll(mockPhotoLibrary); OCMVerifyAll(mockPhotoLibrary);
@ -521,7 +521,7 @@
camera:FLTSourceCameraFront] camera:FLTSourceCameraFront]
maxSize:[[FLTMaxSize alloc] init] maxSize:[[FLTMaxSize alloc] init]
quality:nil quality:nil
fullMetadata:@YES fullMetadata:YES
completion:^(NSString *result, FlutterError *error) { completion:^(NSString *result, FlutterError *error) {
XCTAssertNil(result); XCTAssertNil(result);
XCTAssertEqualObjects(error.code, @"photo_access_denied"); XCTAssertEqualObjects(error.code, @"photo_access_denied");
@ -543,7 +543,7 @@
XCTestExpectation *firstCallExpectation = [self expectationWithDescription:@"first call"]; XCTestExpectation *firstCallExpectation = [self expectationWithDescription:@"first call"];
[plugin pickMultiImageWithMaxSize:[FLTMaxSize makeWithWidth:@100 height:@100] [plugin pickMultiImageWithMaxSize:[FLTMaxSize makeWithWidth:@100 height:@100]
quality:nil quality:nil
fullMetadata:@YES fullMetadata:YES
completion:^(NSArray<NSString *> *result, FlutterError *error) { completion:^(NSArray<NSString *> *result, FlutterError *error) {
XCTAssertNotNil(error); XCTAssertNotNil(error);
XCTAssertEqualObjects(error.code, @"multiple_request"); XCTAssertEqualObjects(error.code, @"multiple_request");
@ -551,7 +551,7 @@
}]; }];
[plugin pickMultiImageWithMaxSize:[FLTMaxSize makeWithWidth:@100 height:@100] [plugin pickMultiImageWithMaxSize:[FLTMaxSize makeWithWidth:@100 height:@100]
quality:nil quality:nil
fullMetadata:@YES fullMetadata:YES
completion:^(NSArray<NSString *> *result, FlutterError *error){ completion:^(NSArray<NSString *> *result, FlutterError *error){
}]; }];
[self waitForExpectationsWithTimeout:30 handler:nil]; [self waitForExpectationsWithTimeout:30 handler:nil];
@ -569,8 +569,8 @@
FLTMediaSelectionOptions *options = FLTMediaSelectionOptions *options =
[FLTMediaSelectionOptions makeWithMaxSize:[FLTMaxSize makeWithWidth:@(100) height:@(200)] [FLTMediaSelectionOptions makeWithMaxSize:[FLTMaxSize makeWithWidth:@(100) height:@(200)]
imageQuality:@(50) imageQuality:@(50)
requestFullMetadata:@YES requestFullMetadata:YES
allowMultiple:@YES]; allowMultiple:YES];
XCTestExpectation *firstCallExpectation = [self expectationWithDescription:@"first call"]; XCTestExpectation *firstCallExpectation = [self expectationWithDescription:@"first call"];
[plugin pickMediaWithMediaSelectionOptions:options [plugin pickMediaWithMediaSelectionOptions:options
completion:^(NSArray<NSString *> *result, FlutterError *error) { completion:^(NSArray<NSString *> *result, FlutterError *error) {
@ -585,11 +585,9 @@
} }
- (void)testPickVideoDuplicateCallCancels API_AVAILABLE(ios(14)) { - (void)testPickVideoDuplicateCallCancels API_AVAILABLE(ios(14)) {
id mockPhotoLibrary = OCMClassMock([PHPhotoLibrary class]); id mockPhotoLibrary = OCMClassMock([AVCaptureDevice class]);
OCMStub([mockPhotoLibrary authorizationStatusForAccessLevel:PHAccessLevelReadWrite]) OCMStub([mockPhotoLibrary authorizationStatusForMediaType:AVMediaTypeVideo])
.andReturn(PHAuthorizationStatusNotDetermined); .andReturn(AVAuthorizationStatusNotDetermined);
OCMExpect([mockPhotoLibrary requestAuthorizationForAccessLevel:PHAccessLevelReadWrite
handler:OCMOCK_ANY]);
FLTImagePickerPlugin *plugin = [[FLTImagePickerPlugin alloc] init]; FLTImagePickerPlugin *plugin = [[FLTImagePickerPlugin alloc] init];

View File

@ -48,7 +48,7 @@ typedef NS_ENUM(NSInteger, ImagePickerClassType) { UIImagePickerClassType, PHPic
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar { + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
FLTImagePickerPlugin *instance = [[FLTImagePickerPlugin alloc] init]; FLTImagePickerPlugin *instance = [[FLTImagePickerPlugin alloc] init];
FLTImagePickerApiSetup(registrar.messenger, instance); SetUpFLTImagePickerApi(registrar.messenger, instance);
} }
- (UIImagePickerController *)createImagePickerController { - (UIImagePickerController *)createImagePickerController {
@ -162,7 +162,7 @@ typedef NS_ENUM(NSInteger, ImagePickerClassType) { UIImagePickerClassType, PHPic
- (void)pickImageWithSource:(nonnull FLTSourceSpecification *)source - (void)pickImageWithSource:(nonnull FLTSourceSpecification *)source
maxSize:(nonnull FLTMaxSize *)maxSize maxSize:(nonnull FLTMaxSize *)maxSize
quality:(nullable NSNumber *)imageQuality quality:(nullable NSNumber *)imageQuality
fullMetadata:(NSNumber *)fullMetadata fullMetadata:(BOOL)fullMetadata
completion: completion:
(nonnull void (^)(NSString *_Nullable, FlutterError *_Nullable))completion { (nonnull void (^)(NSString *_Nullable, FlutterError *_Nullable))completion {
[self cancelInProgressCall]; [self cancelInProgressCall];
@ -178,7 +178,7 @@ typedef NS_ENUM(NSInteger, ImagePickerClassType) { UIImagePickerClassType, PHPic
context.maxSize = maxSize; context.maxSize = maxSize;
context.imageQuality = imageQuality; context.imageQuality = imageQuality;
context.maxImageCount = 1; context.maxImageCount = 1;
context.requestFullMetadata = [fullMetadata boolValue]; context.requestFullMetadata = fullMetadata;
if (source.type == FLTSourceTypeGallery) { // Capture is not possible with PHPicker if (source.type == FLTSourceTypeGallery) { // Capture is not possible with PHPicker
if (@available(iOS 14, *)) { if (@available(iOS 14, *)) {
@ -193,7 +193,7 @@ typedef NS_ENUM(NSInteger, ImagePickerClassType) { UIImagePickerClassType, PHPic
- (void)pickMultiImageWithMaxSize:(nonnull FLTMaxSize *)maxSize - (void)pickMultiImageWithMaxSize:(nonnull FLTMaxSize *)maxSize
quality:(nullable NSNumber *)imageQuality quality:(nullable NSNumber *)imageQuality
fullMetadata:(NSNumber *)fullMetadata fullMetadata:(BOOL)fullMetadata
completion:(nonnull void (^)(NSArray<NSString *> *_Nullable, completion:(nonnull void (^)(NSArray<NSString *> *_Nullable,
FlutterError *_Nullable))completion { FlutterError *_Nullable))completion {
[self cancelInProgressCall]; [self cancelInProgressCall];
@ -201,7 +201,7 @@ typedef NS_ENUM(NSInteger, ImagePickerClassType) { UIImagePickerClassType, PHPic
[[FLTImagePickerMethodCallContext alloc] initWithResult:completion]; [[FLTImagePickerMethodCallContext alloc] initWithResult:completion];
context.maxSize = maxSize; context.maxSize = maxSize;
context.imageQuality = imageQuality; context.imageQuality = imageQuality;
context.requestFullMetadata = [fullMetadata boolValue]; context.requestFullMetadata = fullMetadata;
if (@available(iOS 14, *)) { if (@available(iOS 14, *)) {
[self launchPHPickerWithContext:context]; [self launchPHPickerWithContext:context];
@ -223,7 +223,7 @@ typedef NS_ENUM(NSInteger, ImagePickerClassType) { UIImagePickerClassType, PHPic
context.imageQuality = [mediaSelectionOptions imageQuality]; context.imageQuality = [mediaSelectionOptions imageQuality];
context.requestFullMetadata = [mediaSelectionOptions requestFullMetadata]; context.requestFullMetadata = [mediaSelectionOptions requestFullMetadata];
context.includeVideo = YES; context.includeVideo = YES;
if (![[mediaSelectionOptions allowMultiple] boolValue]) { if (!mediaSelectionOptions.allowMultiple) {
context.maxImageCount = 1; context.maxImageCount = 1;
} }

View File

@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved. // Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Autogenerated from Pigeon (v9.2.5), do not edit directly. // Autogenerated from Pigeon (v13.0.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon // See also: https://pub.dev/packages/pigeon
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@ -18,11 +18,23 @@ typedef NS_ENUM(NSUInteger, FLTSourceCamera) {
FLTSourceCameraFront = 1, FLTSourceCameraFront = 1,
}; };
/// Wrapper for FLTSourceCamera to allow for nullability.
@interface FLTSourceCameraBox : NSObject
@property(nonatomic, assign) FLTSourceCamera value;
- (instancetype)initWithValue:(FLTSourceCamera)value;
@end
typedef NS_ENUM(NSUInteger, FLTSourceType) { typedef NS_ENUM(NSUInteger, FLTSourceType) {
FLTSourceTypeCamera = 0, FLTSourceTypeCamera = 0,
FLTSourceTypeGallery = 1, FLTSourceTypeGallery = 1,
}; };
/// Wrapper for FLTSourceType to allow for nullability.
@interface FLTSourceTypeBox : NSObject
@property(nonatomic, assign) FLTSourceType value;
- (instancetype)initWithValue:(FLTSourceType)value;
@end
@class FLTMaxSize; @class FLTMaxSize;
@class FLTMediaSelectionOptions; @class FLTMediaSelectionOptions;
@class FLTSourceSpecification; @class FLTSourceSpecification;
@ -38,12 +50,12 @@ typedef NS_ENUM(NSUInteger, FLTSourceType) {
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithMaxSize:(FLTMaxSize *)maxSize + (instancetype)makeWithMaxSize:(FLTMaxSize *)maxSize
imageQuality:(nullable NSNumber *)imageQuality imageQuality:(nullable NSNumber *)imageQuality
requestFullMetadata:(NSNumber *)requestFullMetadata requestFullMetadata:(BOOL)requestFullMetadata
allowMultiple:(NSNumber *)allowMultiple; allowMultiple:(BOOL)allowMultiple;
@property(nonatomic, strong) FLTMaxSize *maxSize; @property(nonatomic, strong) FLTMaxSize *maxSize;
@property(nonatomic, strong, nullable) NSNumber *imageQuality; @property(nonatomic, strong, nullable) NSNumber *imageQuality;
@property(nonatomic, strong) NSNumber *requestFullMetadata; @property(nonatomic, assign) BOOL requestFullMetadata;
@property(nonatomic, strong) NSNumber *allowMultiple; @property(nonatomic, assign) BOOL allowMultiple;
@end @end
@interface FLTSourceSpecification : NSObject @interface FLTSourceSpecification : NSObject
@ -61,11 +73,11 @@ NSObject<FlutterMessageCodec> *FLTImagePickerApiGetCodec(void);
- (void)pickImageWithSource:(FLTSourceSpecification *)source - (void)pickImageWithSource:(FLTSourceSpecification *)source
maxSize:(FLTMaxSize *)maxSize maxSize:(FLTMaxSize *)maxSize
quality:(nullable NSNumber *)imageQuality quality:(nullable NSNumber *)imageQuality
fullMetadata:(NSNumber *)requestFullMetadata fullMetadata:(BOOL)requestFullMetadata
completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion;
- (void)pickMultiImageWithMaxSize:(FLTMaxSize *)maxSize - (void)pickMultiImageWithMaxSize:(FLTMaxSize *)maxSize
quality:(nullable NSNumber *)imageQuality quality:(nullable NSNumber *)imageQuality
fullMetadata:(NSNumber *)requestFullMetadata fullMetadata:(BOOL)requestFullMetadata
completion:(void (^)(NSArray<NSString *> *_Nullable, completion:(void (^)(NSArray<NSString *> *_Nullable,
FlutterError *_Nullable))completion; FlutterError *_Nullable))completion;
- (void)pickVideoWithSource:(FLTSourceSpecification *)source - (void)pickVideoWithSource:(FLTSourceSpecification *)source
@ -77,7 +89,7 @@ NSObject<FlutterMessageCodec> *FLTImagePickerApiGetCodec(void);
FlutterError *_Nullable))completion; FlutterError *_Nullable))completion;
@end @end
extern void FLTImagePickerApiSetup(id<FlutterBinaryMessenger> binaryMessenger, extern void SetUpFLTImagePickerApi(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FLTImagePickerApi> *_Nullable api); NSObject<FLTImagePickerApi> *_Nullable api);
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@ -1,16 +1,41 @@
// Copyright 2013 The Flutter Authors. All rights reserved. // Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Autogenerated from Pigeon (v9.2.5), do not edit directly. // Autogenerated from Pigeon (v13.0.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon // See also: https://pub.dev/packages/pigeon
#import "messages.g.h" #import "messages.g.h"
#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h> #import <Flutter/Flutter.h>
#endif
#if !__has_feature(objc_arc) #if !__has_feature(objc_arc)
#error File requires ARC to be enabled. #error File requires ARC to be enabled.
#endif #endif
@implementation FLTSourceCameraBox
- (instancetype)initWithValue:(FLTSourceCamera)value {
self = [super init];
if (self) {
_value = value;
}
return self;
}
@end
@implementation FLTSourceTypeBox
- (instancetype)initWithValue:(FLTSourceType)value {
self = [super init];
if (self) {
_value = value;
}
return self;
}
@end
static NSArray *wrapResult(id result, FlutterError *error) { static NSArray *wrapResult(id result, FlutterError *error) {
if (error) { if (error) {
return @[ return @[
@ -60,8 +85,8 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
} }
- (NSArray *)toList { - (NSArray *)toList {
return @[ return @[
(self.width ?: [NSNull null]), self.width ?: [NSNull null],
(self.height ?: [NSNull null]), self.height ?: [NSNull null],
]; ];
} }
@end @end
@ -69,8 +94,8 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
@implementation FLTMediaSelectionOptions @implementation FLTMediaSelectionOptions
+ (instancetype)makeWithMaxSize:(FLTMaxSize *)maxSize + (instancetype)makeWithMaxSize:(FLTMaxSize *)maxSize
imageQuality:(nullable NSNumber *)imageQuality imageQuality:(nullable NSNumber *)imageQuality
requestFullMetadata:(NSNumber *)requestFullMetadata requestFullMetadata:(BOOL)requestFullMetadata
allowMultiple:(NSNumber *)allowMultiple { allowMultiple:(BOOL)allowMultiple {
FLTMediaSelectionOptions *pigeonResult = [[FLTMediaSelectionOptions alloc] init]; FLTMediaSelectionOptions *pigeonResult = [[FLTMediaSelectionOptions alloc] init];
pigeonResult.maxSize = maxSize; pigeonResult.maxSize = maxSize;
pigeonResult.imageQuality = imageQuality; pigeonResult.imageQuality = imageQuality;
@ -81,12 +106,9 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
+ (FLTMediaSelectionOptions *)fromList:(NSArray *)list { + (FLTMediaSelectionOptions *)fromList:(NSArray *)list {
FLTMediaSelectionOptions *pigeonResult = [[FLTMediaSelectionOptions alloc] init]; FLTMediaSelectionOptions *pigeonResult = [[FLTMediaSelectionOptions alloc] init];
pigeonResult.maxSize = [FLTMaxSize nullableFromList:(GetNullableObjectAtIndex(list, 0))]; pigeonResult.maxSize = [FLTMaxSize nullableFromList:(GetNullableObjectAtIndex(list, 0))];
NSAssert(pigeonResult.maxSize != nil, @"");
pigeonResult.imageQuality = GetNullableObjectAtIndex(list, 1); pigeonResult.imageQuality = GetNullableObjectAtIndex(list, 1);
pigeonResult.requestFullMetadata = GetNullableObjectAtIndex(list, 2); pigeonResult.requestFullMetadata = [GetNullableObjectAtIndex(list, 2) boolValue];
NSAssert(pigeonResult.requestFullMetadata != nil, @""); pigeonResult.allowMultiple = [GetNullableObjectAtIndex(list, 3) boolValue];
pigeonResult.allowMultiple = GetNullableObjectAtIndex(list, 3);
NSAssert(pigeonResult.allowMultiple != nil, @"");
return pigeonResult; return pigeonResult;
} }
+ (nullable FLTMediaSelectionOptions *)nullableFromList:(NSArray *)list { + (nullable FLTMediaSelectionOptions *)nullableFromList:(NSArray *)list {
@ -95,9 +117,9 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
- (NSArray *)toList { - (NSArray *)toList {
return @[ return @[
(self.maxSize ? [self.maxSize toList] : [NSNull null]), (self.maxSize ? [self.maxSize toList] : [NSNull null]),
(self.imageQuality ?: [NSNull null]), self.imageQuality ?: [NSNull null],
(self.requestFullMetadata ?: [NSNull null]), @(self.requestFullMetadata),
(self.allowMultiple ?: [NSNull null]), @(self.allowMultiple),
]; ];
} }
@end @end
@ -184,11 +206,11 @@ NSObject<FlutterMessageCodec> *FLTImagePickerApiGetCodec(void) {
return sSharedObject; return sSharedObject;
} }
void FLTImagePickerApiSetup(id<FlutterBinaryMessenger> binaryMessenger, void SetUpFLTImagePickerApi(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FLTImagePickerApi> *api) { NSObject<FLTImagePickerApi> *api) {
{ {
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.ImagePickerApi.pickImage" initWithName:@"dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickImage"
binaryMessenger:binaryMessenger binaryMessenger:binaryMessenger
codec:FLTImagePickerApiGetCodec()]; codec:FLTImagePickerApiGetCodec()];
if (api) { if (api) {
@ -202,7 +224,7 @@ void FLTImagePickerApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
FLTSourceSpecification *arg_source = GetNullableObjectAtIndex(args, 0); FLTSourceSpecification *arg_source = GetNullableObjectAtIndex(args, 0);
FLTMaxSize *arg_maxSize = GetNullableObjectAtIndex(args, 1); FLTMaxSize *arg_maxSize = GetNullableObjectAtIndex(args, 1);
NSNumber *arg_imageQuality = GetNullableObjectAtIndex(args, 2); NSNumber *arg_imageQuality = GetNullableObjectAtIndex(args, 2);
NSNumber *arg_requestFullMetadata = GetNullableObjectAtIndex(args, 3); BOOL arg_requestFullMetadata = [GetNullableObjectAtIndex(args, 3) boolValue];
[api pickImageWithSource:arg_source [api pickImageWithSource:arg_source
maxSize:arg_maxSize maxSize:arg_maxSize
quality:arg_imageQuality quality:arg_imageQuality
@ -217,7 +239,7 @@ void FLTImagePickerApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
} }
{ {
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.ImagePickerApi.pickMultiImage" initWithName:@"dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMultiImage"
binaryMessenger:binaryMessenger binaryMessenger:binaryMessenger
codec:FLTImagePickerApiGetCodec()]; codec:FLTImagePickerApiGetCodec()];
if (api) { if (api) {
@ -230,7 +252,7 @@ void FLTImagePickerApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
NSArray *args = message; NSArray *args = message;
FLTMaxSize *arg_maxSize = GetNullableObjectAtIndex(args, 0); FLTMaxSize *arg_maxSize = GetNullableObjectAtIndex(args, 0);
NSNumber *arg_imageQuality = GetNullableObjectAtIndex(args, 1); NSNumber *arg_imageQuality = GetNullableObjectAtIndex(args, 1);
NSNumber *arg_requestFullMetadata = GetNullableObjectAtIndex(args, 2); BOOL arg_requestFullMetadata = [GetNullableObjectAtIndex(args, 2) boolValue];
[api pickMultiImageWithMaxSize:arg_maxSize [api pickMultiImageWithMaxSize:arg_maxSize
quality:arg_imageQuality quality:arg_imageQuality
fullMetadata:arg_requestFullMetadata fullMetadata:arg_requestFullMetadata
@ -245,7 +267,7 @@ void FLTImagePickerApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
} }
{ {
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.ImagePickerApi.pickVideo" initWithName:@"dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickVideo"
binaryMessenger:binaryMessenger binaryMessenger:binaryMessenger
codec:FLTImagePickerApiGetCodec()]; codec:FLTImagePickerApiGetCodec()];
if (api) { if (api) {
@ -270,7 +292,7 @@ void FLTImagePickerApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
/// Selects images and videos and returns their paths. /// Selects images and videos and returns their paths.
{ {
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.ImagePickerApi.pickMedia" initWithName:@"dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMedia"
binaryMessenger:binaryMessenger binaryMessenger:binaryMessenger
codec:FLTImagePickerApiGetCodec()]; codec:FLTImagePickerApiGetCodec()];
if (api) { if (api) {

View File

@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved. // Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Autogenerated from Pigeon (v9.2.5), do not edit directly. // Autogenerated from Pigeon (v13.0.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon // See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import
@ -11,6 +11,17 @@ import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
List<Object?> wrapResponse(
{Object? result, PlatformException? error, bool empty = false}) {
if (empty) {
return <Object?>[];
}
if (error == null) {
return <Object?>[result];
}
return <Object?>[error.code, error.message, error.details];
}
enum SourceCamera { enum SourceCamera {
rear, rear,
front, front,
@ -86,17 +97,17 @@ class MediaSelectionOptions {
class SourceSpecification { class SourceSpecification {
SourceSpecification({ SourceSpecification({
required this.type, required this.type,
this.camera, required this.camera,
}); });
SourceType type; SourceType type;
SourceCamera? camera; SourceCamera camera;
Object encode() { Object encode() {
return <Object?>[ return <Object?>[
type.index, type.index,
camera?.index, camera.index,
]; ];
} }
@ -104,7 +115,7 @@ class SourceSpecification {
result as List<Object?>; result as List<Object?>;
return SourceSpecification( return SourceSpecification(
type: SourceType.values[result[0]! as int], type: SourceType.values[result[0]! as int],
camera: result[1] != null ? SourceCamera.values[result[1]! as int] : null, camera: SourceCamera.values[result[1]! as int],
); );
} }
} }
@ -155,7 +166,7 @@ class ImagePickerApi {
Future<String?> pickImage(SourceSpecification arg_source, MaxSize arg_maxSize, Future<String?> pickImage(SourceSpecification arg_source, MaxSize arg_maxSize,
int? arg_imageQuality, bool arg_requestFullMetadata) async { int? arg_imageQuality, bool arg_requestFullMetadata) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.ImagePickerApi.pickImage', codec, 'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickImage', codec,
binaryMessenger: _binaryMessenger); binaryMessenger: _binaryMessenger);
final List<Object?>? replyList = await channel.send(<Object?>[ final List<Object?>? replyList = await channel.send(<Object?>[
arg_source, arg_source,
@ -182,7 +193,8 @@ class ImagePickerApi {
Future<List<String?>> pickMultiImage(MaxSize arg_maxSize, Future<List<String?>> pickMultiImage(MaxSize arg_maxSize,
int? arg_imageQuality, bool arg_requestFullMetadata) async { int? arg_imageQuality, bool arg_requestFullMetadata) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.ImagePickerApi.pickMultiImage', codec, 'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMultiImage',
codec,
binaryMessenger: _binaryMessenger); binaryMessenger: _binaryMessenger);
final List<Object?>? replyList = await channel.send( final List<Object?>? replyList = await channel.send(
<Object?>[arg_maxSize, arg_imageQuality, arg_requestFullMetadata]) <Object?>[arg_maxSize, arg_imageQuality, arg_requestFullMetadata])
@ -211,7 +223,7 @@ class ImagePickerApi {
Future<String?> pickVideo( Future<String?> pickVideo(
SourceSpecification arg_source, int? arg_maxDurationSeconds) async { SourceSpecification arg_source, int? arg_maxDurationSeconds) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.ImagePickerApi.pickVideo', codec, 'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickVideo', codec,
binaryMessenger: _binaryMessenger); binaryMessenger: _binaryMessenger);
final List<Object?>? replyList = await channel final List<Object?>? replyList = await channel
.send(<Object?>[arg_source, arg_maxDurationSeconds]) as List<Object?>?; .send(<Object?>[arg_source, arg_maxDurationSeconds]) as List<Object?>?;
@ -235,7 +247,7 @@ class ImagePickerApi {
Future<List<String?>> pickMedia( Future<List<String?>> pickMedia(
MediaSelectionOptions arg_mediaSelectionOptions) async { MediaSelectionOptions arg_mediaSelectionOptions) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.ImagePickerApi.pickMedia', codec, 'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMedia', codec,
binaryMessenger: _binaryMessenger); binaryMessenger: _binaryMessenger);
final List<Object?>? replyList = await channel final List<Object?>? replyList = await channel
.send(<Object?>[arg_mediaSelectionOptions]) as List<Object?>?; .send(<Object?>[arg_mediaSelectionOptions]) as List<Object?>?;

View File

@ -43,7 +43,7 @@ enum SourceType { camera, gallery }
class SourceSpecification { class SourceSpecification {
SourceSpecification(this.type, this.camera); SourceSpecification(this.type, this.camera);
SourceType type; SourceType type;
SourceCamera? camera; SourceCamera camera;
} }
@HostApi(dartHostTestHandler: 'TestHostImagePickerApi') @HostApi(dartHostTestHandler: 'TestHostImagePickerApi')

View File

@ -2,7 +2,7 @@ name: image_picker_ios
description: iOS implementation of the image_picker plugin. description: iOS implementation of the image_picker plugin.
repository: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_ios repository: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_ios
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22 issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
version: 0.8.8+3 version: 0.8.8+4
environment: environment:
sdk: ">=2.19.0 <4.0.0" sdk: ">=2.19.0 <4.0.0"
@ -25,7 +25,7 @@ dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
mockito: 5.4.1 mockito: 5.4.1
pigeon: ^9.2.4 pigeon: ^13.0.0
topics: topics:
- camera - camera

View File

@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved. // Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Autogenerated from Pigeon (v9.2.5), do not edit directly. // Autogenerated from Pigeon (v13.0.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon // See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, unnecessary_import // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, unnecessary_import
// ignore_for_file: avoid_relative_lib_imports // ignore_for_file: avoid_relative_lib_imports
@ -67,7 +67,7 @@ abstract class TestHostImagePickerApi {
{BinaryMessenger? binaryMessenger}) { {BinaryMessenger? binaryMessenger}) {
{ {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.ImagePickerApi.pickImage', codec, 'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickImage', codec,
binaryMessenger: binaryMessenger); binaryMessenger: binaryMessenger);
if (api == null) { if (api == null) {
_testBinaryMessengerBinding!.defaultBinaryMessenger _testBinaryMessengerBinding!.defaultBinaryMessenger
@ -77,28 +77,36 @@ abstract class TestHostImagePickerApi {
.setMockDecodedMessageHandler<Object?>(channel, .setMockDecodedMessageHandler<Object?>(channel,
(Object? message) async { (Object? message) async {
assert(message != null, assert(message != null,
'Argument for dev.flutter.pigeon.ImagePickerApi.pickImage was null.'); 'Argument for dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickImage was null.');
final List<Object?> args = (message as List<Object?>?)!; final List<Object?> args = (message as List<Object?>?)!;
final SourceSpecification? arg_source = final SourceSpecification? arg_source =
(args[0] as SourceSpecification?); (args[0] as SourceSpecification?);
assert(arg_source != null, assert(arg_source != null,
'Argument for dev.flutter.pigeon.ImagePickerApi.pickImage was null, expected non-null SourceSpecification.'); 'Argument for dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickImage was null, expected non-null SourceSpecification.');
final MaxSize? arg_maxSize = (args[1] as MaxSize?); final MaxSize? arg_maxSize = (args[1] as MaxSize?);
assert(arg_maxSize != null, assert(arg_maxSize != null,
'Argument for dev.flutter.pigeon.ImagePickerApi.pickImage was null, expected non-null MaxSize.'); 'Argument for dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickImage was null, expected non-null MaxSize.');
final int? arg_imageQuality = (args[2] as int?); final int? arg_imageQuality = (args[2] as int?);
final bool? arg_requestFullMetadata = (args[3] as bool?); final bool? arg_requestFullMetadata = (args[3] as bool?);
assert(arg_requestFullMetadata != null, assert(arg_requestFullMetadata != null,
'Argument for dev.flutter.pigeon.ImagePickerApi.pickImage was null, expected non-null bool.'); 'Argument for dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickImage was null, expected non-null bool.');
final String? output = await api.pickImage(arg_source!, arg_maxSize!, try {
arg_imageQuality, arg_requestFullMetadata!); final String? output = await api.pickImage(arg_source!,
return <Object?>[output]; arg_maxSize!, arg_imageQuality, arg_requestFullMetadata!);
return <Object?>[output];
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
}); });
} }
} }
{ {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.ImagePickerApi.pickMultiImage', codec, 'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMultiImage',
codec,
binaryMessenger: binaryMessenger); binaryMessenger: binaryMessenger);
if (api == null) { if (api == null) {
_testBinaryMessengerBinding!.defaultBinaryMessenger _testBinaryMessengerBinding!.defaultBinaryMessenger
@ -108,24 +116,31 @@ abstract class TestHostImagePickerApi {
.setMockDecodedMessageHandler<Object?>(channel, .setMockDecodedMessageHandler<Object?>(channel,
(Object? message) async { (Object? message) async {
assert(message != null, assert(message != null,
'Argument for dev.flutter.pigeon.ImagePickerApi.pickMultiImage was null.'); 'Argument for dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMultiImage was null.');
final List<Object?> args = (message as List<Object?>?)!; final List<Object?> args = (message as List<Object?>?)!;
final MaxSize? arg_maxSize = (args[0] as MaxSize?); final MaxSize? arg_maxSize = (args[0] as MaxSize?);
assert(arg_maxSize != null, assert(arg_maxSize != null,
'Argument for dev.flutter.pigeon.ImagePickerApi.pickMultiImage was null, expected non-null MaxSize.'); 'Argument for dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMultiImage was null, expected non-null MaxSize.');
final int? arg_imageQuality = (args[1] as int?); final int? arg_imageQuality = (args[1] as int?);
final bool? arg_requestFullMetadata = (args[2] as bool?); final bool? arg_requestFullMetadata = (args[2] as bool?);
assert(arg_requestFullMetadata != null, assert(arg_requestFullMetadata != null,
'Argument for dev.flutter.pigeon.ImagePickerApi.pickMultiImage was null, expected non-null bool.'); 'Argument for dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMultiImage was null, expected non-null bool.');
final List<String?> output = await api.pickMultiImage( try {
arg_maxSize!, arg_imageQuality, arg_requestFullMetadata!); final List<String?> output = await api.pickMultiImage(
return <Object?>[output]; arg_maxSize!, arg_imageQuality, arg_requestFullMetadata!);
return <Object?>[output];
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
}); });
} }
} }
{ {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.ImagePickerApi.pickVideo', codec, 'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickVideo', codec,
binaryMessenger: binaryMessenger); binaryMessenger: binaryMessenger);
if (api == null) { if (api == null) {
_testBinaryMessengerBinding!.defaultBinaryMessenger _testBinaryMessengerBinding!.defaultBinaryMessenger
@ -135,22 +150,29 @@ abstract class TestHostImagePickerApi {
.setMockDecodedMessageHandler<Object?>(channel, .setMockDecodedMessageHandler<Object?>(channel,
(Object? message) async { (Object? message) async {
assert(message != null, assert(message != null,
'Argument for dev.flutter.pigeon.ImagePickerApi.pickVideo was null.'); 'Argument for dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickVideo was null.');
final List<Object?> args = (message as List<Object?>?)!; final List<Object?> args = (message as List<Object?>?)!;
final SourceSpecification? arg_source = final SourceSpecification? arg_source =
(args[0] as SourceSpecification?); (args[0] as SourceSpecification?);
assert(arg_source != null, assert(arg_source != null,
'Argument for dev.flutter.pigeon.ImagePickerApi.pickVideo was null, expected non-null SourceSpecification.'); 'Argument for dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickVideo was null, expected non-null SourceSpecification.');
final int? arg_maxDurationSeconds = (args[1] as int?); final int? arg_maxDurationSeconds = (args[1] as int?);
final String? output = try {
await api.pickVideo(arg_source!, arg_maxDurationSeconds); final String? output =
return <Object?>[output]; await api.pickVideo(arg_source!, arg_maxDurationSeconds);
return <Object?>[output];
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
}); });
} }
} }
{ {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.ImagePickerApi.pickMedia', codec, 'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMedia', codec,
binaryMessenger: binaryMessenger); binaryMessenger: binaryMessenger);
if (api == null) { if (api == null) {
_testBinaryMessengerBinding!.defaultBinaryMessenger _testBinaryMessengerBinding!.defaultBinaryMessenger
@ -160,15 +182,22 @@ abstract class TestHostImagePickerApi {
.setMockDecodedMessageHandler<Object?>(channel, .setMockDecodedMessageHandler<Object?>(channel,
(Object? message) async { (Object? message) async {
assert(message != null, assert(message != null,
'Argument for dev.flutter.pigeon.ImagePickerApi.pickMedia was null.'); 'Argument for dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMedia was null.');
final List<Object?> args = (message as List<Object?>?)!; final List<Object?> args = (message as List<Object?>?)!;
final MediaSelectionOptions? arg_mediaSelectionOptions = final MediaSelectionOptions? arg_mediaSelectionOptions =
(args[0] as MediaSelectionOptions?); (args[0] as MediaSelectionOptions?);
assert(arg_mediaSelectionOptions != null, assert(arg_mediaSelectionOptions != null,
'Argument for dev.flutter.pigeon.ImagePickerApi.pickMedia was null, expected non-null MediaSelectionOptions.'); 'Argument for dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMedia was null, expected non-null MediaSelectionOptions.');
final List<String?> output = try {
await api.pickMedia(arg_mediaSelectionOptions!); final List<String?> output =
return <Object?>[output]; await api.pickMedia(arg_mediaSelectionOptions!);
return <Object?>[output];
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
}); });
} }
} }