Skip to content

Update file_selector_* to the latest pigeon #3562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/file_selector/file_selector_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.1+2

* Updates to `pigeon` version 9.

## 0.5.1+1

* Clarifies explanation of endorsement in README.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// 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 (v3.2.5), do not edit directly.
// Autogenerated from Pigeon (v9.1.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import <Foundation/Foundation.h>

@protocol FlutterBinaryMessenger;
@protocol FlutterMessageCodec;
@class FlutterError;
Expand Down
56 changes: 23 additions & 33 deletions packages/file_selector/file_selector_ios/ios/Classes/messages.g.m
Original file line number Diff line number Diff line change
@@ -1,42 +1,33 @@
// 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 (v3.2.5), do not edit directly.
// Autogenerated from Pigeon (v9.1.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import "messages.g.h"
#import <Flutter/Flutter.h>

#if !__has_feature(objc_arc)
#error File requires ARC to be enabled.
#endif

static NSDictionary<NSString *, id> *wrapResult(id result, FlutterError *error) {
NSDictionary *errorDict = (NSDictionary *)[NSNull null];
static NSArray *wrapResult(id result, FlutterError *error) {
if (error) {
errorDict = @{
@"code" : (error.code ?: [NSNull null]),
@"message" : (error.message ?: [NSNull null]),
@"details" : (error.details ?: [NSNull null]),
};
return @[
error.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null]
];
}
return @{
@"result" : (result ?: [NSNull null]),
@"error" : errorDict,
};
}
static id GetNullableObject(NSDictionary *dict, id key) {
id result = dict[key];
return (result == [NSNull null]) ? nil : result;
return @[ result ?: [NSNull null] ];
}
static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
id result = array[key];
return (result == [NSNull null]) ? nil : result;
}

@interface FFSFileSelectorConfig ()
+ (FFSFileSelectorConfig *)fromMap:(NSDictionary *)dict;
+ (nullable FFSFileSelectorConfig *)nullableFromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
+ (FFSFileSelectorConfig *)fromList:(NSArray *)list;
+ (nullable FFSFileSelectorConfig *)nullableFromList:(NSArray *)list;
- (NSArray *)toList;
@end

@implementation FFSFileSelectorConfig
Expand All @@ -47,22 +38,22 @@ + (instancetype)makeWithUtis:(NSArray<NSString *> *)utis
pigeonResult.allowMultiSelection = allowMultiSelection;
return pigeonResult;
}
+ (FFSFileSelectorConfig *)fromMap:(NSDictionary *)dict {
+ (FFSFileSelectorConfig *)fromList:(NSArray *)list {
FFSFileSelectorConfig *pigeonResult = [[FFSFileSelectorConfig alloc] init];
pigeonResult.utis = GetNullableObject(dict, @"utis");
pigeonResult.utis = GetNullableObjectAtIndex(list, 0);
NSAssert(pigeonResult.utis != nil, @"");
pigeonResult.allowMultiSelection = GetNullableObject(dict, @"allowMultiSelection");
pigeonResult.allowMultiSelection = GetNullableObjectAtIndex(list, 1);
NSAssert(pigeonResult.allowMultiSelection != nil, @"");
return pigeonResult;
}
+ (nullable FFSFileSelectorConfig *)nullableFromMap:(NSDictionary *)dict {
return (dict) ? [FFSFileSelectorConfig fromMap:dict] : nil;
+ (nullable FFSFileSelectorConfig *)nullableFromList:(NSArray *)list {
return (list) ? [FFSFileSelectorConfig fromList:list] : nil;
}
- (NSDictionary *)toMap {
return @{
@"utis" : (self.utis ?: [NSNull null]),
@"allowMultiSelection" : (self.allowMultiSelection ?: [NSNull null]),
};
- (NSArray *)toList {
return @[
(self.utis ?: [NSNull null]),
(self.allowMultiSelection ?: [NSNull null]),
];
}
@end

Expand All @@ -72,8 +63,7 @@ @implementation FFSFileSelectorApiCodecReader
- (nullable id)readValueOfType:(UInt8)type {
switch (type) {
case 128:
return [FFSFileSelectorConfig fromMap:[self readValue]];

return [FFSFileSelectorConfig fromList:[self readValue]];
default:
return [super readValueOfType:type];
}
Expand All @@ -86,7 +76,7 @@ @implementation FFSFileSelectorApiCodecWriter
- (void)writeValue:(id)value {
if ([value isKindOfClass:[FFSFileSelectorConfig class]]) {
[self writeByte:128];
[self writeValue:[value toMap]];
[self writeValue:[value toList]];
} else {
[super writeValue:value];
}
Expand All @@ -105,8 +95,8 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data {
@end

NSObject<FlutterMessageCodec> *FFSFileSelectorApiGetCodec() {
static dispatch_once_t sPred = 0;
static FlutterStandardMessageCodec *sSharedObject = nil;
static dispatch_once_t sPred = 0;
dispatch_once(&sPred, ^{
FFSFileSelectorApiCodecReaderWriter *readerWriter =
[[FFSFileSelectorApiCodecReaderWriter alloc] init];
Expand Down
46 changes: 22 additions & 24 deletions packages/file_selector/file_selector_ios/lib/src/messages.g.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// 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 (v3.2.5), do not edit directly.
// Autogenerated from Pigeon (v9.1.1), 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

import 'dart:async';
import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List;
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;

import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer;
import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';

class FileSelectorConfig {
Expand All @@ -17,20 +18,21 @@ class FileSelectorConfig {
});

List<String?> utis;

bool allowMultiSelection;

Object encode() {
final Map<Object?, Object?> pigeonMap = <Object?, Object?>{};
pigeonMap['utis'] = utis;
pigeonMap['allowMultiSelection'] = allowMultiSelection;
return pigeonMap;
return <Object?>[
utis,
allowMultiSelection,
];
}

static FileSelectorConfig decode(Object message) {
final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>;
static FileSelectorConfig decode(Object result) {
result as List<Object?>;
return FileSelectorConfig(
utis: (pigeonMap['utis'] as List<Object?>?)!.cast<String?>(),
allowMultiSelection: pigeonMap['allowMultiSelection']! as bool,
utis: (result[0] as List<Object?>?)!.cast<String?>(),
allowMultiSelection: result[1]! as bool,
);
}
}
Expand All @@ -52,7 +54,6 @@ class _FileSelectorApiCodec extends StandardMessageCodec {
switch (type) {
case 128:
return FileSelectorConfig.decode(readValue(buffer)!);

default:
return super.readValueOfType(type, buffer);
}
Expand All @@ -65,7 +66,6 @@ class FileSelectorApi {
/// BinaryMessenger will be used which routes to the host platform.
FileSelectorApi({BinaryMessenger? binaryMessenger})
: _binaryMessenger = binaryMessenger;

final BinaryMessenger? _binaryMessenger;

static const MessageCodec<Object?> codec = _FileSelectorApiCodec();
Expand All @@ -74,28 +74,26 @@ class FileSelectorApi {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.FileSelectorApi.openFile', codec,
binaryMessenger: _binaryMessenger);
final Map<Object?, Object?>? replyMap =
await channel.send(<Object?>[arg_config]) as Map<Object?, Object?>?;
if (replyMap == null) {
final List<Object?>? replyList =
await channel.send(<Object?>[arg_config]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyMap['error'] != null) {
final Map<Object?, Object?> error =
(replyMap['error'] as Map<Object?, Object?>?)!;
} else if (replyList.length > 1) {
throw PlatformException(
code: (error['code'] as String?)!,
message: error['message'] as String?,
details: error['details'],
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else if (replyMap['result'] == null) {
} else if (replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
return (replyMap['result'] as List<Object?>?)!.cast<String?>();
return (replyList[0] as List<Object?>?)!.cast<String?>();
}
}
}
7 changes: 3 additions & 4 deletions packages/file_selector/file_selector_ios/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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+1
version: 0.5.1+2

environment:
sdk: ">=2.18.0 <4.0.0"
Expand All @@ -22,9 +22,8 @@ dependencies:
sdk: flutter

dev_dependencies:
build_runner: 2.1.11
build_runner: ^2.3.0
flutter_test:
sdk: flutter
mockito: 5.3.2
pigeon: ^3.2.5

pigeon: ^9.1.0
13 changes: 5 additions & 8 deletions packages/file_selector/file_selector_ios/test/test_api.g.dart
Original file line number Diff line number Diff line change
@@ -1,19 +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 (v3.2.5), do not edit directly.
// Autogenerated from Pigeon (v9.1.1), 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
import 'dart:async';
import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List;
import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer;
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

// This line has been hand-edited due to
// https://github.com/flutter/flutter/issues/97744
// ignore: directives_ordering
import 'package:file_selector_ios/src/messages.g.dart';

class _TestFileSelectorApiCodec extends StandardMessageCodec {
Expand All @@ -33,7 +30,6 @@ class _TestFileSelectorApiCodec extends StandardMessageCodec {
switch (type) {
case 128:
return FileSelectorConfig.decode(readValue(buffer)!);

default:
return super.readValueOfType(type, buffer);
}
Expand All @@ -44,6 +40,7 @@ abstract class TestFileSelectorApi {
static const MessageCodec<Object?> codec = _TestFileSelectorApiCodec();

Future<List<String?>> openFile(FileSelectorConfig config);

static void setup(TestFileSelectorApi? api,
{BinaryMessenger? binaryMessenger}) {
{
Expand All @@ -62,7 +59,7 @@ abstract class TestFileSelectorApi {
assert(arg_config != null,
'Argument for dev.flutter.pigeon.FileSelectorApi.openFile was null, expected non-null FileSelectorConfig.');
final List<String?> output = await api.openFile(arg_config!);
return <Object?, Object?>{'result': output};
return <Object?>[output];
});
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/file_selector/file_selector_macos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.0+7

* Updates to `pigeon` version 9.

## 0.9.0+6

* Clarifies explanation of endorsement in README.
Expand Down
Loading