diff --git a/packages/file_selector/file_selector_ios/CHANGELOG.md b/packages/file_selector/file_selector_ios/CHANGELOG.md index f09aba9966c..d66052a6527 100644 --- a/packages/file_selector/file_selector_ios/CHANGELOG.md +++ b/packages/file_selector/file_selector_ios/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.5.1+7 + +* Updates to Pigeon 13. + ## 0.5.1+6 * Adds pub topics to package metadata. diff --git a/packages/file_selector/file_selector_ios/example/ios/RunnerTests/FileSelectorTests.m b/packages/file_selector/file_selector_ios/example/ios/RunnerTests/FileSelectorTests.m index c52aad59f58..521beb7bc57 100644 --- a/packages/file_selector/file_selector_ios/example/ios/RunnerTests/FileSelectorTests.m +++ b/packages/file_selector/file_selector_ios/example/ios/RunnerTests/FileSelectorTests.m @@ -23,8 +23,7 @@ - (void)testPickerPresents { plugin.documentPickerViewControllerOverride = picker; plugin.presentingViewControllerOverride = mockPresentingVC; - [plugin openFileSelectorWithConfig:[FFSFileSelectorConfig makeWithUtis:@[] - allowMultiSelection:@NO] + [plugin openFileSelectorWithConfig:[FFSFileSelectorConfig makeWithUtis:@[] allowMultiSelection:NO] completion:^(NSArray *paths, FlutterError *error){ }]; @@ -42,7 +41,7 @@ - (void)testReturnsPickedFiles { inMode:UIDocumentPickerModeImport]; plugin.documentPickerViewControllerOverride = picker; [plugin openFileSelectorWithConfig:[FFSFileSelectorConfig makeWithUtis:@[] - allowMultiSelection:@YES] + allowMultiSelection:YES] completion:^(NSArray *paths, FlutterError *error) { NSArray *expectedPaths = @[ @"/file1.txt", @"/file2.txt" ]; XCTAssertEqualObjects(paths, expectedPaths); @@ -63,8 +62,7 @@ - (void)testCancellingPickerReturnsNil { plugin.documentPickerViewControllerOverride = picker; XCTestExpectation *completionWasCalled = [self expectationWithDescription:@"completion"]; - [plugin openFileSelectorWithConfig:[FFSFileSelectorConfig makeWithUtis:@[] - allowMultiSelection:@NO] + [plugin openFileSelectorWithConfig:[FFSFileSelectorConfig makeWithUtis:@[] allowMultiSelection:NO] completion:^(NSArray *paths, FlutterError *error) { XCTAssertEqual(paths.count, 0); [completionWasCalled fulfill]; diff --git a/packages/file_selector/file_selector_ios/ios/Classes/FFSFileSelectorPlugin.m b/packages/file_selector/file_selector_ios/ios/Classes/FFSFileSelectorPlugin.m index 8a92cc3131c..ee9b840d5c4 100644 --- a/packages/file_selector/file_selector_ios/ios/Classes/FFSFileSelectorPlugin.m +++ b/packages/file_selector/file_selector_ios/ios/Classes/FFSFileSelectorPlugin.m @@ -21,7 +21,7 @@ - (void)openFileSelectorWithConfig:(FFSFileSelectorConfig *)config initWithDocumentTypes:config.utis inMode:UIDocumentPickerModeImport]; documentPicker.delegate = self; - documentPicker.allowsMultipleSelection = config.allowMultiSelection.boolValue; + documentPicker.allowsMultipleSelection = config.allowMultiSelection; UIViewController *presentingVC = self.presentingViewControllerOverride @@ -41,7 +41,7 @@ - (void)openFileSelectorWithConfig:(FFSFileSelectorConfig *)config + (void)registerWithRegistrar:(NSObject *)registrar { FFSFileSelectorPlugin *plugin = [[FFSFileSelectorPlugin alloc] init]; - FFSFileSelectorApiSetup(registrar.messenger, plugin); + SetUpFFSFileSelectorApi(registrar.messenger, plugin); } #pragma mark - UIDocumentPickerDelegate diff --git a/packages/file_selector/file_selector_ios/ios/Classes/messages.g.h b/packages/file_selector/file_selector_ios/ios/Classes/messages.g.h index bbaca5b5df6..d0f9d977f4b 100644 --- a/packages/file_selector/file_selector_ios/ios/Classes/messages.g.h +++ b/packages/file_selector/file_selector_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.4), do not edit directly. +// Autogenerated from Pigeon (v13.0.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #import @@ -19,9 +19,9 @@ NS_ASSUME_NONNULL_BEGIN /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithUtis:(NSArray *)utis - allowMultiSelection:(NSNumber *)allowMultiSelection; -@property(nonatomic, strong) NSArray *utis; -@property(nonatomic, strong) NSNumber *allowMultiSelection; + allowMultiSelection:(BOOL)allowMultiSelection; +@property(nonatomic, copy) NSArray *utis; +@property(nonatomic, assign) BOOL allowMultiSelection; @end /// The codec used by FFSFileSelectorApi. @@ -33,7 +33,7 @@ NSObject *FFSFileSelectorApiGetCodec(void); FlutterError *_Nullable))completion; @end -extern void FFSFileSelectorApiSetup(id binaryMessenger, +extern void SetUpFFSFileSelectorApi(id binaryMessenger, NSObject *_Nullable api); NS_ASSUME_NONNULL_END diff --git a/packages/file_selector/file_selector_ios/ios/Classes/messages.g.m b/packages/file_selector/file_selector_ios/ios/Classes/messages.g.m index 8a4ee261bd7..1905261653b 100644 --- a/packages/file_selector/file_selector_ios/ios/Classes/messages.g.m +++ b/packages/file_selector/file_selector_ios/ios/Classes/messages.g.m @@ -1,11 +1,16 @@ // 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.4), 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. @@ -32,7 +37,7 @@ - (NSArray *)toList; @implementation FFSFileSelectorConfig + (instancetype)makeWithUtis:(NSArray *)utis - allowMultiSelection:(NSNumber *)allowMultiSelection { + allowMultiSelection:(BOOL)allowMultiSelection { FFSFileSelectorConfig *pigeonResult = [[FFSFileSelectorConfig alloc] init]; pigeonResult.utis = utis; pigeonResult.allowMultiSelection = allowMultiSelection; @@ -41,9 +46,7 @@ + (instancetype)makeWithUtis:(NSArray *)utis + (FFSFileSelectorConfig *)fromList:(NSArray *)list { FFSFileSelectorConfig *pigeonResult = [[FFSFileSelectorConfig alloc] init]; pigeonResult.utis = GetNullableObjectAtIndex(list, 0); - NSAssert(pigeonResult.utis != nil, @""); - pigeonResult.allowMultiSelection = GetNullableObjectAtIndex(list, 1); - NSAssert(pigeonResult.allowMultiSelection != nil, @""); + pigeonResult.allowMultiSelection = [GetNullableObjectAtIndex(list, 1) boolValue]; return pigeonResult; } + (nullable FFSFileSelectorConfig *)nullableFromList:(NSArray *)list { @@ -51,8 +54,8 @@ + (nullable FFSFileSelectorConfig *)nullableFromList:(NSArray *)list { } - (NSArray *)toList { return @[ - (self.utis ?: [NSNull null]), - (self.allowMultiSelection ?: [NSNull null]), + self.utis ?: [NSNull null], + @(self.allowMultiSelection), ]; } @end @@ -105,11 +108,11 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { return sSharedObject; } -void FFSFileSelectorApiSetup(id binaryMessenger, +void SetUpFFSFileSelectorApi(id binaryMessenger, NSObject *api) { { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.FileSelectorApi.openFile" + initWithName:@"dev.flutter.pigeon.file_selector_ios.FileSelectorApi.openFile" binaryMessenger:binaryMessenger codec:FFSFileSelectorApiGetCodec()]; if (api) { diff --git a/packages/file_selector/file_selector_ios/lib/src/messages.g.dart b/packages/file_selector/file_selector_ios/lib/src/messages.g.dart index c623de74dc4..6ec723c8b70 100644 --- a/packages/file_selector/file_selector_ios/lib/src/messages.g.dart +++ b/packages/file_selector/file_selector_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.4), 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]; +} + class FileSelectorConfig { FileSelectorConfig({ required this.utis, @@ -72,7 +83,7 @@ class FileSelectorApi { Future> openFile(FileSelectorConfig arg_config) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.FileSelectorApi.openFile', codec, + 'dev.flutter.pigeon.file_selector_ios.FileSelectorApi.openFile', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_config]) as List?; diff --git a/packages/file_selector/file_selector_ios/pubspec.yaml b/packages/file_selector/file_selector_ios/pubspec.yaml index af8591c0a9d..58c0def0720 100644 --- a/packages/file_selector/file_selector_ios/pubspec.yaml +++ b/packages/file_selector/file_selector_ios/pubspec.yaml @@ -2,7 +2,7 @@ name: file_selector_ios description: iOS implementation of the file_selector plugin. repository: https://github.com/flutter/packages/tree/main/packages/file_selector/file_selector_ios issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22 -version: 0.5.1+6 +version: 0.5.1+7 environment: sdk: ">=2.19.0 <4.0.0" @@ -26,7 +26,7 @@ dev_dependencies: flutter_test: sdk: flutter mockito: 5.4.1 - pigeon: ^9.2.4 + pigeon: ^13.0.0 topics: - files diff --git a/packages/file_selector/file_selector_ios/test/test_api.g.dart b/packages/file_selector/file_selector_ios/test/test_api.g.dart index 5648f26bdee..7b0ace73ef9 100644 --- a/packages/file_selector/file_selector_ios/test/test_api.g.dart +++ b/packages/file_selector/file_selector_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.4), 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 @@ -47,7 +47,8 @@ abstract class TestFileSelectorApi { {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.FileSelectorApi.openFile', codec, + 'dev.flutter.pigeon.file_selector_ios.FileSelectorApi.openFile', + codec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger @@ -57,14 +58,21 @@ abstract class TestFileSelectorApi { .setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.FileSelectorApi.openFile was null.'); + 'Argument for dev.flutter.pigeon.file_selector_ios.FileSelectorApi.openFile was null.'); final List args = (message as List?)!; final FileSelectorConfig? arg_config = (args[0] as FileSelectorConfig?); assert(arg_config != null, - 'Argument for dev.flutter.pigeon.FileSelectorApi.openFile was null, expected non-null FileSelectorConfig.'); - final List output = await api.openFile(arg_config!); - return [output]; + 'Argument for dev.flutter.pigeon.file_selector_ios.FileSelectorApi.openFile was null, expected non-null FileSelectorConfig.'); + try { + final List output = await api.openFile(arg_config!); + return [output]; + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } }); } }