From b195bde182c35360935be38a01476b84ebb3901c Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Tue, 31 Oct 2023 09:08:54 -0700 Subject: [PATCH] [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 --- .../image_picker_ios/CHANGELOG.md | 4 + .../ios/RunnerTests/ImagePickerPluginTests.m | 40 +++++---- .../ios/Classes/FLTImagePickerPlugin.m | 12 +-- .../image_picker_ios/ios/Classes/messages.g.h | 28 ++++-- .../image_picker_ios/ios/Classes/messages.g.m | 62 +++++++++----- .../image_picker_ios/lib/src/messages.g.dart | 30 +++++-- .../image_picker_ios/pigeons/messages.dart | 2 +- .../image_picker_ios/pubspec.yaml | 4 +- .../image_picker_ios/test/test_api.g.dart | 85 +++++++++++++------ 9 files changed, 172 insertions(+), 95 deletions(-) diff --git a/packages/image_picker/image_picker_ios/CHANGELOG.md b/packages/image_picker/image_picker_ios/CHANGELOG.md index 83b953a7ef..4433ea9c91 100644 --- a/packages/image_picker/image_picker_ios/CHANGELOG.md +++ b/packages/image_picker/image_picker_ios/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.8.8+4 + +* Updates to Pigeon 13. + ## 0.8.8+3 * Fixes a possible crash when calling a picker method while another is waiting on permissions. diff --git a/packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImagePickerPluginTests.m b/packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImagePickerPluginTests.m index 4f22c319a7..36ca8ec965 100644 --- a/packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImagePickerPluginTests.m +++ b/packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImagePickerPluginTests.m @@ -56,7 +56,7 @@ camera:FLTSourceCameraRear] maxSize:[[FLTMaxSize alloc] init] quality:nil - fullMetadata:@YES + fullMetadata:YES completion:^(NSString *_Nullable result, FlutterError *_Nullable error){ }]; @@ -89,7 +89,7 @@ camera:FLTSourceCameraFront] maxSize:[[FLTMaxSize alloc] init] quality:nil - fullMetadata:@YES + fullMetadata:YES completion:^(NSString *_Nullable result, FlutterError *_Nullable error){ }]; @@ -174,7 +174,7 @@ [plugin pickMultiImageWithMaxSize:[FLTMaxSize makeWithWidth:@(100) height:@(200)] quality:@(50) - fullMetadata:@YES + fullMetadata:YES completion:^(NSArray *_Nullable result, FlutterError *_Nullable error){ }]; @@ -197,8 +197,8 @@ FLTMediaSelectionOptions *mediaSelectionOptions = [FLTMediaSelectionOptions makeWithMaxSize:[FLTMaxSize makeWithWidth:@(100) height:@(200)] imageQuality:@(50) - requestFullMetadata:@YES - allowMultiple:@YES]; + requestFullMetadata:YES + allowMultiple:YES]; [plugin pickMediaWithMediaSelectionOptions:mediaSelectionOptions completion:^(NSArray *_Nullable result, @@ -219,7 +219,7 @@ camera:FLTSourceCameraFront] maxSize:[[FLTMaxSize alloc] init] quality:nil - fullMetadata:@NO + fullMetadata:NO completion:^(NSString *_Nullable result, FlutterError *_Nullable error){ }]; @@ -235,7 +235,7 @@ [plugin pickMultiImageWithMaxSize:[[FLTMaxSize alloc] init] quality:nil - fullMetadata:@NO + fullMetadata:NO completion:^(NSArray *_Nullable result, FlutterError *_Nullable error){ }]; @@ -253,8 +253,8 @@ FLTMediaSelectionOptions *mediaSelectionOptions = [FLTMediaSelectionOptions makeWithMaxSize:[FLTMaxSize makeWithWidth:@(100) height:@(200)] imageQuality:@(50) - requestFullMetadata:@YES - allowMultiple:@YES]; + requestFullMetadata:YES + allowMultiple:YES]; [plugin pickMediaWithMediaSelectionOptions:mediaSelectionOptions @@ -279,7 +279,7 @@ camera:FLTSourceCameraRear] maxSize:[[FLTMaxSize alloc] init] quality:nil - fullMetadata:@YES + fullMetadata:YES completion:^(NSString *_Nullable result, FlutterError *_Nullable error){ }]; @@ -502,7 +502,7 @@ camera:FLTSourceCameraFront] maxSize:[[FLTMaxSize alloc] init] quality:nil - fullMetadata:@YES + fullMetadata:YES completion:^(NSString *result, FlutterError *error){ }]; OCMVerifyAll(mockPhotoLibrary); @@ -521,7 +521,7 @@ camera:FLTSourceCameraFront] maxSize:[[FLTMaxSize alloc] init] quality:nil - fullMetadata:@YES + fullMetadata:YES completion:^(NSString *result, FlutterError *error) { XCTAssertNil(result); XCTAssertEqualObjects(error.code, @"photo_access_denied"); @@ -543,7 +543,7 @@ XCTestExpectation *firstCallExpectation = [self expectationWithDescription:@"first call"]; [plugin pickMultiImageWithMaxSize:[FLTMaxSize makeWithWidth:@100 height:@100] quality:nil - fullMetadata:@YES + fullMetadata:YES completion:^(NSArray *result, FlutterError *error) { XCTAssertNotNil(error); XCTAssertEqualObjects(error.code, @"multiple_request"); @@ -551,7 +551,7 @@ }]; [plugin pickMultiImageWithMaxSize:[FLTMaxSize makeWithWidth:@100 height:@100] quality:nil - fullMetadata:@YES + fullMetadata:YES completion:^(NSArray *result, FlutterError *error){ }]; [self waitForExpectationsWithTimeout:30 handler:nil]; @@ -569,8 +569,8 @@ FLTMediaSelectionOptions *options = [FLTMediaSelectionOptions makeWithMaxSize:[FLTMaxSize makeWithWidth:@(100) height:@(200)] imageQuality:@(50) - requestFullMetadata:@YES - allowMultiple:@YES]; + requestFullMetadata:YES + allowMultiple:YES]; XCTestExpectation *firstCallExpectation = [self expectationWithDescription:@"first call"]; [plugin pickMediaWithMediaSelectionOptions:options completion:^(NSArray *result, FlutterError *error) { @@ -585,11 +585,9 @@ } - (void)testPickVideoDuplicateCallCancels API_AVAILABLE(ios(14)) { - id mockPhotoLibrary = OCMClassMock([PHPhotoLibrary class]); - OCMStub([mockPhotoLibrary authorizationStatusForAccessLevel:PHAccessLevelReadWrite]) - .andReturn(PHAuthorizationStatusNotDetermined); - OCMExpect([mockPhotoLibrary requestAuthorizationForAccessLevel:PHAccessLevelReadWrite - handler:OCMOCK_ANY]); + id mockPhotoLibrary = OCMClassMock([AVCaptureDevice class]); + OCMStub([mockPhotoLibrary authorizationStatusForMediaType:AVMediaTypeVideo]) + .andReturn(AVAuthorizationStatusNotDetermined); FLTImagePickerPlugin *plugin = [[FLTImagePickerPlugin alloc] init]; diff --git a/packages/image_picker/image_picker_ios/ios/Classes/FLTImagePickerPlugin.m b/packages/image_picker/image_picker_ios/ios/Classes/FLTImagePickerPlugin.m index 6a4fde82bb..f699ca98c2 100644 --- a/packages/image_picker/image_picker_ios/ios/Classes/FLTImagePickerPlugin.m +++ b/packages/image_picker/image_picker_ios/ios/Classes/FLTImagePickerPlugin.m @@ -48,7 +48,7 @@ typedef NS_ENUM(NSInteger, ImagePickerClassType) { UIImagePickerClassType, PHPic + (void)registerWithRegistrar:(NSObject *)registrar { FLTImagePickerPlugin *instance = [[FLTImagePickerPlugin alloc] init]; - FLTImagePickerApiSetup(registrar.messenger, instance); + SetUpFLTImagePickerApi(registrar.messenger, instance); } - (UIImagePickerController *)createImagePickerController { @@ -162,7 +162,7 @@ typedef NS_ENUM(NSInteger, ImagePickerClassType) { UIImagePickerClassType, PHPic - (void)pickImageWithSource:(nonnull FLTSourceSpecification *)source maxSize:(nonnull FLTMaxSize *)maxSize quality:(nullable NSNumber *)imageQuality - fullMetadata:(NSNumber *)fullMetadata + fullMetadata:(BOOL)fullMetadata completion: (nonnull void (^)(NSString *_Nullable, FlutterError *_Nullable))completion { [self cancelInProgressCall]; @@ -178,7 +178,7 @@ typedef NS_ENUM(NSInteger, ImagePickerClassType) { UIImagePickerClassType, PHPic context.maxSize = maxSize; context.imageQuality = imageQuality; context.maxImageCount = 1; - context.requestFullMetadata = [fullMetadata boolValue]; + context.requestFullMetadata = fullMetadata; if (source.type == FLTSourceTypeGallery) { // Capture is not possible with PHPicker if (@available(iOS 14, *)) { @@ -193,7 +193,7 @@ typedef NS_ENUM(NSInteger, ImagePickerClassType) { UIImagePickerClassType, PHPic - (void)pickMultiImageWithMaxSize:(nonnull FLTMaxSize *)maxSize quality:(nullable NSNumber *)imageQuality - fullMetadata:(NSNumber *)fullMetadata + fullMetadata:(BOOL)fullMetadata completion:(nonnull void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion { [self cancelInProgressCall]; @@ -201,7 +201,7 @@ typedef NS_ENUM(NSInteger, ImagePickerClassType) { UIImagePickerClassType, PHPic [[FLTImagePickerMethodCallContext alloc] initWithResult:completion]; context.maxSize = maxSize; context.imageQuality = imageQuality; - context.requestFullMetadata = [fullMetadata boolValue]; + context.requestFullMetadata = fullMetadata; if (@available(iOS 14, *)) { [self launchPHPickerWithContext:context]; @@ -223,7 +223,7 @@ typedef NS_ENUM(NSInteger, ImagePickerClassType) { UIImagePickerClassType, PHPic context.imageQuality = [mediaSelectionOptions imageQuality]; context.requestFullMetadata = [mediaSelectionOptions requestFullMetadata]; context.includeVideo = YES; - if (![[mediaSelectionOptions allowMultiple] boolValue]) { + if (!mediaSelectionOptions.allowMultiple) { context.maxImageCount = 1; } diff --git a/packages/image_picker/image_picker_ios/ios/Classes/messages.g.h b/packages/image_picker/image_picker_ios/ios/Classes/messages.g.h index 4e2c4b28c1..593f88296b 100644 --- a/packages/image_picker/image_picker_ios/ios/Classes/messages.g.h +++ b/packages/image_picker/image_picker_ios/ios/Classes/messages.g.h @@ -1,7 +1,7 @@ // 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. -// 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 #import @@ -18,11 +18,23 @@ typedef NS_ENUM(NSUInteger, FLTSourceCamera) { 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) { FLTSourceTypeCamera = 0, 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 FLTMediaSelectionOptions; @class FLTSourceSpecification; @@ -38,12 +50,12 @@ typedef NS_ENUM(NSUInteger, FLTSourceType) { - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithMaxSize:(FLTMaxSize *)maxSize imageQuality:(nullable NSNumber *)imageQuality - requestFullMetadata:(NSNumber *)requestFullMetadata - allowMultiple:(NSNumber *)allowMultiple; + requestFullMetadata:(BOOL)requestFullMetadata + allowMultiple:(BOOL)allowMultiple; @property(nonatomic, strong) FLTMaxSize *maxSize; @property(nonatomic, strong, nullable) NSNumber *imageQuality; -@property(nonatomic, strong) NSNumber *requestFullMetadata; -@property(nonatomic, strong) NSNumber *allowMultiple; +@property(nonatomic, assign) BOOL requestFullMetadata; +@property(nonatomic, assign) BOOL allowMultiple; @end @interface FLTSourceSpecification : NSObject @@ -61,11 +73,11 @@ NSObject *FLTImagePickerApiGetCodec(void); - (void)pickImageWithSource:(FLTSourceSpecification *)source maxSize:(FLTMaxSize *)maxSize quality:(nullable NSNumber *)imageQuality - fullMetadata:(NSNumber *)requestFullMetadata + fullMetadata:(BOOL)requestFullMetadata completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; - (void)pickMultiImageWithMaxSize:(FLTMaxSize *)maxSize quality:(nullable NSNumber *)imageQuality - fullMetadata:(NSNumber *)requestFullMetadata + fullMetadata:(BOOL)requestFullMetadata completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion; - (void)pickVideoWithSource:(FLTSourceSpecification *)source @@ -77,7 +89,7 @@ NSObject *FLTImagePickerApiGetCodec(void); FlutterError *_Nullable))completion; @end -extern void FLTImagePickerApiSetup(id binaryMessenger, +extern void SetUpFLTImagePickerApi(id binaryMessenger, NSObject *_Nullable api); NS_ASSUME_NONNULL_END diff --git a/packages/image_picker/image_picker_ios/ios/Classes/messages.g.m b/packages/image_picker/image_picker_ios/ios/Classes/messages.g.m index 2a24f83670..1659cb8870 100644 --- a/packages/image_picker/image_picker_ios/ios/Classes/messages.g.m +++ b/packages/image_picker/image_picker_ios/ios/Classes/messages.g.m @@ -1,16 +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. -// 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 #import "messages.g.h" + +#if TARGET_OS_OSX +#import +#else #import +#endif #if !__has_feature(objc_arc) #error File requires ARC to be enabled. #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) { if (error) { return @[ @@ -60,8 +85,8 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { } - (NSArray *)toList { return @[ - (self.width ?: [NSNull null]), - (self.height ?: [NSNull null]), + self.width ?: [NSNull null], + self.height ?: [NSNull null], ]; } @end @@ -69,8 +94,8 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { @implementation FLTMediaSelectionOptions + (instancetype)makeWithMaxSize:(FLTMaxSize *)maxSize imageQuality:(nullable NSNumber *)imageQuality - requestFullMetadata:(NSNumber *)requestFullMetadata - allowMultiple:(NSNumber *)allowMultiple { + requestFullMetadata:(BOOL)requestFullMetadata + allowMultiple:(BOOL)allowMultiple { FLTMediaSelectionOptions *pigeonResult = [[FLTMediaSelectionOptions alloc] init]; pigeonResult.maxSize = maxSize; pigeonResult.imageQuality = imageQuality; @@ -81,12 +106,9 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { + (FLTMediaSelectionOptions *)fromList:(NSArray *)list { FLTMediaSelectionOptions *pigeonResult = [[FLTMediaSelectionOptions alloc] init]; pigeonResult.maxSize = [FLTMaxSize nullableFromList:(GetNullableObjectAtIndex(list, 0))]; - NSAssert(pigeonResult.maxSize != nil, @""); pigeonResult.imageQuality = GetNullableObjectAtIndex(list, 1); - pigeonResult.requestFullMetadata = GetNullableObjectAtIndex(list, 2); - NSAssert(pigeonResult.requestFullMetadata != nil, @""); - pigeonResult.allowMultiple = GetNullableObjectAtIndex(list, 3); - NSAssert(pigeonResult.allowMultiple != nil, @""); + pigeonResult.requestFullMetadata = [GetNullableObjectAtIndex(list, 2) boolValue]; + pigeonResult.allowMultiple = [GetNullableObjectAtIndex(list, 3) boolValue]; return pigeonResult; } + (nullable FLTMediaSelectionOptions *)nullableFromList:(NSArray *)list { @@ -95,9 +117,9 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { - (NSArray *)toList { return @[ (self.maxSize ? [self.maxSize toList] : [NSNull null]), - (self.imageQuality ?: [NSNull null]), - (self.requestFullMetadata ?: [NSNull null]), - (self.allowMultiple ?: [NSNull null]), + self.imageQuality ?: [NSNull null], + @(self.requestFullMetadata), + @(self.allowMultiple), ]; } @end @@ -184,11 +206,11 @@ NSObject *FLTImagePickerApiGetCodec(void) { return sSharedObject; } -void FLTImagePickerApiSetup(id binaryMessenger, +void SetUpFLTImagePickerApi(id binaryMessenger, NSObject *api) { { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.ImagePickerApi.pickImage" + initWithName:@"dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickImage" binaryMessenger:binaryMessenger codec:FLTImagePickerApiGetCodec()]; if (api) { @@ -202,7 +224,7 @@ void FLTImagePickerApiSetup(id binaryMessenger, FLTSourceSpecification *arg_source = GetNullableObjectAtIndex(args, 0); FLTMaxSize *arg_maxSize = GetNullableObjectAtIndex(args, 1); NSNumber *arg_imageQuality = GetNullableObjectAtIndex(args, 2); - NSNumber *arg_requestFullMetadata = GetNullableObjectAtIndex(args, 3); + BOOL arg_requestFullMetadata = [GetNullableObjectAtIndex(args, 3) boolValue]; [api pickImageWithSource:arg_source maxSize:arg_maxSize quality:arg_imageQuality @@ -217,7 +239,7 @@ void FLTImagePickerApiSetup(id binaryMessenger, } { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.ImagePickerApi.pickMultiImage" + initWithName:@"dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMultiImage" binaryMessenger:binaryMessenger codec:FLTImagePickerApiGetCodec()]; if (api) { @@ -230,7 +252,7 @@ void FLTImagePickerApiSetup(id binaryMessenger, NSArray *args = message; FLTMaxSize *arg_maxSize = GetNullableObjectAtIndex(args, 0); NSNumber *arg_imageQuality = GetNullableObjectAtIndex(args, 1); - NSNumber *arg_requestFullMetadata = GetNullableObjectAtIndex(args, 2); + BOOL arg_requestFullMetadata = [GetNullableObjectAtIndex(args, 2) boolValue]; [api pickMultiImageWithMaxSize:arg_maxSize quality:arg_imageQuality fullMetadata:arg_requestFullMetadata @@ -245,7 +267,7 @@ void FLTImagePickerApiSetup(id binaryMessenger, } { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.ImagePickerApi.pickVideo" + initWithName:@"dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickVideo" binaryMessenger:binaryMessenger codec:FLTImagePickerApiGetCodec()]; if (api) { @@ -270,7 +292,7 @@ void FLTImagePickerApiSetup(id binaryMessenger, /// Selects images and videos and returns their paths. { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.ImagePickerApi.pickMedia" + initWithName:@"dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMedia" binaryMessenger:binaryMessenger codec:FLTImagePickerApiGetCodec()]; if (api) { diff --git a/packages/image_picker/image_picker_ios/lib/src/messages.g.dart b/packages/image_picker/image_picker_ios/lib/src/messages.g.dart index d9ce3624c8..0ab7d1b518 100644 --- a/packages/image_picker/image_picker_ios/lib/src/messages.g.dart +++ b/packages/image_picker/image_picker_ios/lib/src/messages.g.dart @@ -1,7 +1,7 @@ // 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. -// 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 // 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/services.dart'; +List wrapResponse( + {Object? result, PlatformException? error, bool empty = false}) { + if (empty) { + return []; + } + if (error == null) { + return [result]; + } + return [error.code, error.message, error.details]; +} + enum SourceCamera { rear, front, @@ -86,17 +97,17 @@ class MediaSelectionOptions { class SourceSpecification { SourceSpecification({ required this.type, - this.camera, + required this.camera, }); SourceType type; - SourceCamera? camera; + SourceCamera camera; Object encode() { return [ type.index, - camera?.index, + camera.index, ]; } @@ -104,7 +115,7 @@ class SourceSpecification { result as List; return SourceSpecification( 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 pickImage(SourceSpecification arg_source, MaxSize arg_maxSize, int? arg_imageQuality, bool arg_requestFullMetadata) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ImagePickerApi.pickImage', codec, + 'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickImage', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([ arg_source, @@ -182,7 +193,8 @@ class ImagePickerApi { Future> pickMultiImage(MaxSize arg_maxSize, int? arg_imageQuality, bool arg_requestFullMetadata) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ImagePickerApi.pickMultiImage', codec, + 'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMultiImage', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send( [arg_maxSize, arg_imageQuality, arg_requestFullMetadata]) @@ -211,7 +223,7 @@ class ImagePickerApi { Future pickVideo( SourceSpecification arg_source, int? arg_maxDurationSeconds) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ImagePickerApi.pickVideo', codec, + 'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickVideo', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_source, arg_maxDurationSeconds]) as List?; @@ -235,7 +247,7 @@ class ImagePickerApi { Future> pickMedia( MediaSelectionOptions arg_mediaSelectionOptions) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ImagePickerApi.pickMedia', codec, + 'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMedia', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_mediaSelectionOptions]) as List?; diff --git a/packages/image_picker/image_picker_ios/pigeons/messages.dart b/packages/image_picker/image_picker_ios/pigeons/messages.dart index be6b61a3fa..0e69598304 100644 --- a/packages/image_picker/image_picker_ios/pigeons/messages.dart +++ b/packages/image_picker/image_picker_ios/pigeons/messages.dart @@ -43,7 +43,7 @@ enum SourceType { camera, gallery } class SourceSpecification { SourceSpecification(this.type, this.camera); SourceType type; - SourceCamera? camera; + SourceCamera camera; } @HostApi(dartHostTestHandler: 'TestHostImagePickerApi') diff --git a/packages/image_picker/image_picker_ios/pubspec.yaml b/packages/image_picker/image_picker_ios/pubspec.yaml index 121dedc41f..1de34ae7e7 100755 --- a/packages/image_picker/image_picker_ios/pubspec.yaml +++ b/packages/image_picker/image_picker_ios/pubspec.yaml @@ -2,7 +2,7 @@ name: image_picker_ios description: iOS implementation of the image_picker plugin. 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 -version: 0.8.8+3 +version: 0.8.8+4 environment: sdk: ">=2.19.0 <4.0.0" @@ -25,7 +25,7 @@ dev_dependencies: flutter_test: sdk: flutter mockito: 5.4.1 - pigeon: ^9.2.4 + pigeon: ^13.0.0 topics: - camera diff --git a/packages/image_picker/image_picker_ios/test/test_api.g.dart b/packages/image_picker/image_picker_ios/test/test_api.g.dart index ca1a7af01a..a2d02666ba 100644 --- a/packages/image_picker/image_picker_ios/test/test_api.g.dart +++ b/packages/image_picker/image_picker_ios/test/test_api.g.dart @@ -1,7 +1,7 @@ // 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. -// 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 // 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 @@ -67,7 +67,7 @@ abstract class TestHostImagePickerApi { {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ImagePickerApi.pickImage', codec, + 'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickImage', codec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger @@ -77,28 +77,36 @@ abstract class TestHostImagePickerApi { .setMockDecodedMessageHandler(channel, (Object? message) async { 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 args = (message as List?)!; final SourceSpecification? arg_source = (args[0] as SourceSpecification?); 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?); 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 bool? arg_requestFullMetadata = (args[3] as bool?); assert(arg_requestFullMetadata != null, - 'Argument for dev.flutter.pigeon.ImagePickerApi.pickImage was null, expected non-null bool.'); - final String? output = await api.pickImage(arg_source!, arg_maxSize!, - arg_imageQuality, arg_requestFullMetadata!); - return [output]; + 'Argument for dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickImage was null, expected non-null bool.'); + try { + final String? output = await api.pickImage(arg_source!, + arg_maxSize!, arg_imageQuality, arg_requestFullMetadata!); + return [output]; + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ImagePickerApi.pickMultiImage', codec, + 'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMultiImage', + codec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger @@ -108,24 +116,31 @@ abstract class TestHostImagePickerApi { .setMockDecodedMessageHandler(channel, (Object? message) async { 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 args = (message as List?)!; final MaxSize? arg_maxSize = (args[0] as MaxSize?); 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 bool? arg_requestFullMetadata = (args[2] as bool?); assert(arg_requestFullMetadata != null, - 'Argument for dev.flutter.pigeon.ImagePickerApi.pickMultiImage was null, expected non-null bool.'); - final List output = await api.pickMultiImage( - arg_maxSize!, arg_imageQuality, arg_requestFullMetadata!); - return [output]; + 'Argument for dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMultiImage was null, expected non-null bool.'); + try { + final List output = await api.pickMultiImage( + arg_maxSize!, arg_imageQuality, arg_requestFullMetadata!); + return [output]; + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ImagePickerApi.pickVideo', codec, + 'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickVideo', codec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger @@ -135,22 +150,29 @@ abstract class TestHostImagePickerApi { .setMockDecodedMessageHandler(channel, (Object? message) async { 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 args = (message as List?)!; final SourceSpecification? arg_source = (args[0] as SourceSpecification?); 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 String? output = - await api.pickVideo(arg_source!, arg_maxDurationSeconds); - return [output]; + try { + final String? output = + await api.pickVideo(arg_source!, arg_maxDurationSeconds); + return [output]; + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ImagePickerApi.pickMedia', codec, + 'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMedia', codec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger @@ -160,15 +182,22 @@ abstract class TestHostImagePickerApi { .setMockDecodedMessageHandler(channel, (Object? message) async { 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 args = (message as List?)!; final MediaSelectionOptions? arg_mediaSelectionOptions = (args[0] as MediaSelectionOptions?); assert(arg_mediaSelectionOptions != null, - 'Argument for dev.flutter.pigeon.ImagePickerApi.pickMedia was null, expected non-null MediaSelectionOptions.'); - final List output = - await api.pickMedia(arg_mediaSelectionOptions!); - return [output]; + 'Argument for dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMedia was null, expected non-null MediaSelectionOptions.'); + try { + final List output = + await api.pickMedia(arg_mediaSelectionOptions!); + return [output]; + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } }); } }