mirror of
https://github.com/flutter/packages.git
synced 2025-07-01 07:08:10 +08:00
[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:
@ -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.
|
||||
|
@ -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<NSString *> *_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<NSString *> *_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<NSString *> *_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<NSString *> *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<NSString *> *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<NSString *> *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];
|
||||
|
||||
|
@ -48,7 +48,7 @@ typedef NS_ENUM(NSInteger, ImagePickerClassType) { UIImagePickerClassType, PHPic
|
||||
|
||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)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<NSString *> *_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;
|
||||
}
|
||||
|
||||
|
@ -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 <Foundation/Foundation.h>
|
||||
@ -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<FlutterMessageCodec> *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<NSString *> *_Nullable,
|
||||
FlutterError *_Nullable))completion;
|
||||
- (void)pickVideoWithSource:(FLTSourceSpecification *)source
|
||||
@ -77,7 +89,7 @@ NSObject<FlutterMessageCodec> *FLTImagePickerApiGetCodec(void);
|
||||
FlutterError *_Nullable))completion;
|
||||
@end
|
||||
|
||||
extern void FLTImagePickerApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
|
||||
extern void SetUpFLTImagePickerApi(id<FlutterBinaryMessenger> binaryMessenger,
|
||||
NSObject<FLTImagePickerApi> *_Nullable api);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@ -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 <FlutterMacOS/FlutterMacOS.h>
|
||||
#else
|
||||
#import <Flutter/Flutter.h>
|
||||
#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<FlutterMessageCodec> *FLTImagePickerApiGetCodec(void) {
|
||||
return sSharedObject;
|
||||
}
|
||||
|
||||
void FLTImagePickerApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
|
||||
void SetUpFLTImagePickerApi(id<FlutterBinaryMessenger> binaryMessenger,
|
||||
NSObject<FLTImagePickerApi> *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<FlutterBinaryMessenger> 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<FlutterBinaryMessenger> 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<FlutterBinaryMessenger> 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<FlutterBinaryMessenger> 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<FlutterBinaryMessenger> 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) {
|
||||
|
@ -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<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 {
|
||||
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 <Object?>[
|
||||
type.index,
|
||||
camera?.index,
|
||||
camera.index,
|
||||
];
|
||||
}
|
||||
|
||||
@ -104,7 +115,7 @@ class SourceSpecification {
|
||||
result as List<Object?>;
|
||||
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<String?> pickImage(SourceSpecification arg_source, MaxSize arg_maxSize,
|
||||
int? arg_imageQuality, bool arg_requestFullMetadata) async {
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.ImagePickerApi.pickImage', codec,
|
||||
'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickImage', codec,
|
||||
binaryMessenger: _binaryMessenger);
|
||||
final List<Object?>? replyList = await channel.send(<Object?>[
|
||||
arg_source,
|
||||
@ -182,7 +193,8 @@ class ImagePickerApi {
|
||||
Future<List<String?>> pickMultiImage(MaxSize arg_maxSize,
|
||||
int? arg_imageQuality, bool arg_requestFullMetadata) async {
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.ImagePickerApi.pickMultiImage', codec,
|
||||
'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMultiImage',
|
||||
codec,
|
||||
binaryMessenger: _binaryMessenger);
|
||||
final List<Object?>? replyList = await channel.send(
|
||||
<Object?>[arg_maxSize, arg_imageQuality, arg_requestFullMetadata])
|
||||
@ -211,7 +223,7 @@ class ImagePickerApi {
|
||||
Future<String?> pickVideo(
|
||||
SourceSpecification arg_source, int? arg_maxDurationSeconds) async {
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.ImagePickerApi.pickVideo', codec,
|
||||
'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickVideo', codec,
|
||||
binaryMessenger: _binaryMessenger);
|
||||
final List<Object?>? replyList = await channel
|
||||
.send(<Object?>[arg_source, arg_maxDurationSeconds]) as List<Object?>?;
|
||||
@ -235,7 +247,7 @@ class ImagePickerApi {
|
||||
Future<List<String?>> pickMedia(
|
||||
MediaSelectionOptions arg_mediaSelectionOptions) async {
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.ImagePickerApi.pickMedia', codec,
|
||||
'dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMedia', codec,
|
||||
binaryMessenger: _binaryMessenger);
|
||||
final List<Object?>? replyList = await channel
|
||||
.send(<Object?>[arg_mediaSelectionOptions]) as List<Object?>?;
|
||||
|
@ -43,7 +43,7 @@ enum SourceType { camera, gallery }
|
||||
class SourceSpecification {
|
||||
SourceSpecification(this.type, this.camera);
|
||||
SourceType type;
|
||||
SourceCamera? camera;
|
||||
SourceCamera camera;
|
||||
}
|
||||
|
||||
@HostApi(dartHostTestHandler: 'TestHostImagePickerApi')
|
||||
|
@ -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
|
||||
|
@ -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<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'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<Object?>(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<Object?> args = (message as List<Object?>?)!;
|
||||
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 <Object?>[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 <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?>(
|
||||
'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<Object?>(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<Object?> args = (message as List<Object?>?)!;
|
||||
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<String?> output = await api.pickMultiImage(
|
||||
arg_maxSize!, arg_imageQuality, arg_requestFullMetadata!);
|
||||
return <Object?>[output];
|
||||
'Argument for dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMultiImage was null, expected non-null bool.');
|
||||
try {
|
||||
final List<String?> output = await api.pickMultiImage(
|
||||
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?>(
|
||||
'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<Object?>(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<Object?> args = (message as List<Object?>?)!;
|
||||
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 <Object?>[output];
|
||||
try {
|
||||
final String? 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?>(
|
||||
'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<Object?>(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<Object?> args = (message as List<Object?>?)!;
|
||||
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<String?> output =
|
||||
await api.pickMedia(arg_mediaSelectionOptions!);
|
||||
return <Object?>[output];
|
||||
'Argument for dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickMedia was null, expected non-null MediaSelectionOptions.');
|
||||
try {
|
||||
final List<String?> 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()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user