Skip to content

Commit 8522c9e

Browse files
[various] Update iOS/macOS Pigeon versions (#8226)
Updates iOS and macOS plugin implementations that were still using Pigeon 10/11 to the latest version (22). This picks up some minor improvements to serialization, as well as newer dependencies that can avoid resolver issues in flutter/flutter tests (see linked issue). Most of this PR is auto-generated via the repo tool's `update-dependency` command; only minor manual updates were required (mostly to test code). Fixes flutter/flutter#159803
1 parent 953c683 commit 8522c9e

File tree

22 files changed

+784
-332
lines changed

22 files changed

+784
-332
lines changed

packages/ios_platform_images/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 0.2.4+1
22

3+
* Updates to Pigeon v22.
34
* Updates minimum supported SDK version to Flutter 3.19/Dart 3.3.
45

56
## 0.2.4

packages/ios_platform_images/ios/ios_platform_images/Sources/ios_platform_images/messages.g.swift

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// Autogenerated from Pigeon (v11.0.1), do not edit directly.
4+
// Autogenerated from Pigeon (v22.6.4), do not edit directly.
55
// See also: https://pub.dev/packages/pigeon
66

77
import Foundation
@@ -14,15 +14,36 @@ import Foundation
1414
#error("Unsupported platform.")
1515
#endif
1616

17-
private func isNullish(_ value: Any?) -> Bool {
18-
return value is NSNull || value == nil
17+
/// Error class for passing custom error details to Dart side.
18+
final class PigeonError: Error {
19+
let code: String
20+
let message: String?
21+
let details: Any?
22+
23+
init(code: String, message: String?, details: Any?) {
24+
self.code = code
25+
self.message = message
26+
self.details = details
27+
}
28+
29+
var localizedDescription: String {
30+
return
31+
"PigeonError(code: \(code), message: \(message ?? "<nil>"), details: \(details ?? "<nil>")"
32+
}
1933
}
2034

2135
private func wrapResult(_ result: Any?) -> [Any?] {
2236
return [result]
2337
}
2438

2539
private func wrapError(_ error: Any) -> [Any?] {
40+
if let pigeonError = error as? PigeonError {
41+
return [
42+
pigeonError.code,
43+
pigeonError.message,
44+
pigeonError.details,
45+
]
46+
}
2647
if let flutterError = error as? FlutterError {
2748
return [
2849
flutterError.code,
@@ -37,6 +58,10 @@ private func wrapError(_ error: Any) -> [Any?] {
3758
]
3859
}
3960

61+
private func isNullish(_ value: Any?) -> Bool {
62+
return value is NSNull || value == nil
63+
}
64+
4065
private func nilOrValue<T>(_ value: Any?) -> T? {
4166
if value is NSNull { return nil }
4267
return value as! T?
@@ -51,9 +76,10 @@ struct PlatformImageData {
5176
/// The image's scale factor.
5277
var scale: Double
5378

54-
static func fromList(_ list: [Any?]) -> PlatformImageData? {
55-
let data = list[0] as! FlutterStandardTypedData
56-
let scale = list[1] as! Double
79+
// swift-format-ignore: AlwaysUseLowerCamelCase
80+
static func fromList(_ pigeonVar_list: [Any?]) -> PlatformImageData? {
81+
let data = pigeonVar_list[0] as! FlutterStandardTypedData
82+
let scale = pigeonVar_list[1] as! Double
5783

5884
return PlatformImageData(
5985
data: data,
@@ -67,40 +93,41 @@ struct PlatformImageData {
6793
]
6894
}
6995
}
70-
private class PlatformImagesApiCodecReader: FlutterStandardReader {
96+
97+
private class messagesPigeonCodecReader: FlutterStandardReader {
7198
override func readValue(ofType type: UInt8) -> Any? {
7299
switch type {
73-
case 128:
100+
case 129:
74101
return PlatformImageData.fromList(self.readValue() as! [Any?])
75102
default:
76103
return super.readValue(ofType: type)
77104
}
78105
}
79106
}
80107

81-
private class PlatformImagesApiCodecWriter: FlutterStandardWriter {
108+
private class messagesPigeonCodecWriter: FlutterStandardWriter {
82109
override func writeValue(_ value: Any) {
83110
if let value = value as? PlatformImageData {
84-
super.writeByte(128)
111+
super.writeByte(129)
85112
super.writeValue(value.toList())
86113
} else {
87114
super.writeValue(value)
88115
}
89116
}
90117
}
91118

92-
private class PlatformImagesApiCodecReaderWriter: FlutterStandardReaderWriter {
119+
private class messagesPigeonCodecReaderWriter: FlutterStandardReaderWriter {
93120
override func reader(with data: Data) -> FlutterStandardReader {
94-
return PlatformImagesApiCodecReader(data: data)
121+
return messagesPigeonCodecReader(data: data)
95122
}
96123

97124
override func writer(with data: NSMutableData) -> FlutterStandardWriter {
98-
return PlatformImagesApiCodecWriter(data: data)
125+
return messagesPigeonCodecWriter(data: data)
99126
}
100127
}
101128

102-
class PlatformImagesApiCodec: FlutterStandardMessageCodec {
103-
static let shared = PlatformImagesApiCodec(readerWriter: PlatformImagesApiCodecReaderWriter())
129+
class messagesPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable {
130+
static let shared = messagesPigeonCodec(readerWriter: messagesPigeonCodecReaderWriter())
104131
}
105132

106133
/// Generated protocol from Pigeon that represents a handler of messages from Flutter.
@@ -115,14 +142,17 @@ protocol PlatformImagesApi {
115142

116143
/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.
117144
class PlatformImagesApiSetup {
118-
/// The codec used by PlatformImagesApi.
119-
static var codec: FlutterStandardMessageCodec { PlatformImagesApiCodec.shared }
145+
static var codec: FlutterStandardMessageCodec { messagesPigeonCodec.shared }
120146
/// Sets up an instance of `PlatformImagesApi` to handle messages through the `binaryMessenger`.
121-
static func setUp(binaryMessenger: FlutterBinaryMessenger, api: PlatformImagesApi?) {
147+
static func setUp(
148+
binaryMessenger: FlutterBinaryMessenger, api: PlatformImagesApi?,
149+
messageChannelSuffix: String = ""
150+
) {
151+
let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : ""
122152
/// Returns the URL for the given resource, or null if no such resource is
123153
/// found.
124154
let resolveUrlChannel = FlutterBasicMessageChannel(
125-
name: "dev.flutter.pigeon.ios_platform_images.PlatformImagesApi.resolveUrl",
155+
name: "dev.flutter.pigeon.ios_platform_images.PlatformImagesApi.resolveUrl\(channelSuffix)",
126156
binaryMessenger: binaryMessenger, codec: codec)
127157
if let api = api {
128158
resolveUrlChannel.setMessageHandler { message, reply in
@@ -142,7 +172,7 @@ class PlatformImagesApiSetup {
142172
/// Returns the data for the image resource with the given name, or null if
143173
/// no such resource is found.
144174
let loadImageChannel = FlutterBasicMessageChannel(
145-
name: "dev.flutter.pigeon.ios_platform_images.PlatformImagesApi.loadImage",
175+
name: "dev.flutter.pigeon.ios_platform_images.PlatformImagesApi.loadImage\(channelSuffix)",
146176
binaryMessenger: binaryMessenger, codec: codec)
147177
if let api = api {
148178
loadImageChannel.setMessageHandler { message, reply in
Lines changed: 62 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// Autogenerated from Pigeon (v11.0.1), do not edit directly.
4+
// Autogenerated from Pigeon (v22.6.4), do not edit directly.
55
// See also: https://pub.dev/packages/pigeon
6-
// 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
6+
// 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, no_leading_underscores_for_local_identifiers
77

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

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

14+
PlatformException _createConnectionError(String channelName) {
15+
return PlatformException(
16+
code: 'channel-error',
17+
message: 'Unable to establish connection on channel: "$channelName".',
18+
);
19+
}
20+
1421
/// A serialization of a platform image's data.
1522
class PlatformImageData {
1623
PlatformImageData({
@@ -40,12 +47,15 @@ class PlatformImageData {
4047
}
4148
}
4249

43-
class _PlatformImagesApiCodec extends StandardMessageCodec {
44-
const _PlatformImagesApiCodec();
50+
class _PigeonCodec extends StandardMessageCodec {
51+
const _PigeonCodec();
4552
@override
4653
void writeValue(WriteBuffer buffer, Object? value) {
47-
if (value is PlatformImageData) {
48-
buffer.putUint8(128);
54+
if (value is int) {
55+
buffer.putUint8(4);
56+
buffer.putInt64(value);
57+
} else if (value is PlatformImageData) {
58+
buffer.putUint8(129);
4959
writeValue(buffer, value.encode());
5060
} else {
5161
super.writeValue(buffer, value);
@@ -55,7 +65,7 @@ class _PlatformImagesApiCodec extends StandardMessageCodec {
5565
@override
5666
Object? readValueOfType(int type, ReadBuffer buffer) {
5767
switch (type) {
58-
case 128:
68+
case 129:
5969
return PlatformImageData.decode(readValue(buffer)!);
6070
default:
6171
return super.readValueOfType(type, buffer);
@@ -67,60 +77,66 @@ class PlatformImagesApi {
6777
/// Constructor for [PlatformImagesApi]. The [binaryMessenger] named argument is
6878
/// available for dependency injection. If it is left null, the default
6979
/// BinaryMessenger will be used which routes to the host platform.
70-
PlatformImagesApi({BinaryMessenger? binaryMessenger})
71-
: _binaryMessenger = binaryMessenger;
72-
final BinaryMessenger? _binaryMessenger;
80+
PlatformImagesApi(
81+
{BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
82+
: pigeonVar_binaryMessenger = binaryMessenger,
83+
pigeonVar_messageChannelSuffix =
84+
messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
85+
final BinaryMessenger? pigeonVar_binaryMessenger;
86+
87+
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
7388

74-
static const MessageCodec<Object?> codec = _PlatformImagesApiCodec();
89+
final String pigeonVar_messageChannelSuffix;
7590

7691
/// Returns the URL for the given resource, or null if no such resource is
7792
/// found.
78-
Future<String?> resolveUrl(
79-
String arg_resourceName, String? arg_extension) async {
80-
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
81-
'dev.flutter.pigeon.ios_platform_images.PlatformImagesApi.resolveUrl',
82-
codec,
83-
binaryMessenger: _binaryMessenger);
84-
final List<Object?>? replyList = await channel
85-
.send(<Object?>[arg_resourceName, arg_extension]) as List<Object?>?;
86-
if (replyList == null) {
87-
throw PlatformException(
88-
code: 'channel-error',
89-
message: 'Unable to establish connection on channel.',
90-
);
91-
} else if (replyList.length > 1) {
93+
Future<String?> resolveUrl(String resourceName, String? extension) async {
94+
final String pigeonVar_channelName =
95+
'dev.flutter.pigeon.ios_platform_images.PlatformImagesApi.resolveUrl$pigeonVar_messageChannelSuffix';
96+
final BasicMessageChannel<Object?> pigeonVar_channel =
97+
BasicMessageChannel<Object?>(
98+
pigeonVar_channelName,
99+
pigeonChannelCodec,
100+
binaryMessenger: pigeonVar_binaryMessenger,
101+
);
102+
final List<Object?>? pigeonVar_replyList = await pigeonVar_channel
103+
.send(<Object?>[resourceName, extension]) as List<Object?>?;
104+
if (pigeonVar_replyList == null) {
105+
throw _createConnectionError(pigeonVar_channelName);
106+
} else if (pigeonVar_replyList.length > 1) {
92107
throw PlatformException(
93-
code: replyList[0]! as String,
94-
message: replyList[1] as String?,
95-
details: replyList[2],
108+
code: pigeonVar_replyList[0]! as String,
109+
message: pigeonVar_replyList[1] as String?,
110+
details: pigeonVar_replyList[2],
96111
);
97112
} else {
98-
return (replyList[0] as String?);
113+
return (pigeonVar_replyList[0] as String?);
99114
}
100115
}
101116

102117
/// Returns the data for the image resource with the given name, or null if
103118
/// no such resource is found.
104-
Future<PlatformImageData?> loadImage(String arg_name) async {
105-
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
106-
'dev.flutter.pigeon.ios_platform_images.PlatformImagesApi.loadImage',
107-
codec,
108-
binaryMessenger: _binaryMessenger);
109-
final List<Object?>? replyList =
110-
await channel.send(<Object?>[arg_name]) as List<Object?>?;
111-
if (replyList == null) {
112-
throw PlatformException(
113-
code: 'channel-error',
114-
message: 'Unable to establish connection on channel.',
115-
);
116-
} else if (replyList.length > 1) {
119+
Future<PlatformImageData?> loadImage(String name) async {
120+
final String pigeonVar_channelName =
121+
'dev.flutter.pigeon.ios_platform_images.PlatformImagesApi.loadImage$pigeonVar_messageChannelSuffix';
122+
final BasicMessageChannel<Object?> pigeonVar_channel =
123+
BasicMessageChannel<Object?>(
124+
pigeonVar_channelName,
125+
pigeonChannelCodec,
126+
binaryMessenger: pigeonVar_binaryMessenger,
127+
);
128+
final List<Object?>? pigeonVar_replyList =
129+
await pigeonVar_channel.send(<Object?>[name]) as List<Object?>?;
130+
if (pigeonVar_replyList == null) {
131+
throw _createConnectionError(pigeonVar_channelName);
132+
} else if (pigeonVar_replyList.length > 1) {
117133
throw PlatformException(
118-
code: replyList[0]! as String,
119-
message: replyList[1] as String?,
120-
details: replyList[2],
134+
code: pigeonVar_replyList[0]! as String,
135+
message: pigeonVar_replyList[1] as String?,
136+
details: pigeonVar_replyList[2],
121137
);
122138
} else {
123-
return (replyList[0] as PlatformImageData?);
139+
return (pigeonVar_replyList[0] as PlatformImageData?);
124140
}
125141
}
126142
}

packages/ios_platform_images/pigeons/messages.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:pigeon/pigeon.dart';
77
@ConfigurePigeon(PigeonOptions(
88
dartOut: 'lib/src/messages.g.dart',
99
swiftOut:
10-
'ios/ios_platform_images/Sources/ios_platform_messages/messages.g.swift',
10+
'ios/ios_platform_images/Sources/ios_platform_images/messages.g.swift',
1111
copyrightHeader: 'pigeons/copyright.txt',
1212
))
1313

packages/ios_platform_images/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: ios_platform_images
22
description: A plugin to share images between Flutter and iOS in add-to-app setups.
33
repository: https://github.com/flutter/packages/tree/main/packages/ios_platform_images
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+ios_platform_images%22
5-
version: 0.2.4
5+
version: 0.2.4+1
66

77
environment:
88
sdk: ^3.3.0
@@ -21,7 +21,7 @@ dependencies:
2121
dev_dependencies:
2222
flutter_test:
2323
sdk: flutter
24-
pigeon: ^11.0.0
24+
pigeon: ^22.6.4
2525

2626
topics:
2727
- image

packages/ios_platform_images/test/ios_platform_images_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,12 @@ class FakePlatformImagesApi implements PlatformImagesApi {
6464
passedExtension = extension;
6565
return resolutionResult;
6666
}
67+
68+
@override
69+
// ignore: non_constant_identifier_names
70+
BinaryMessenger? get pigeonVar_binaryMessenger => null;
71+
72+
@override
73+
// ignore: non_constant_identifier_names
74+
String get pigeonVar_messageChannelSuffix => '';
6775
}

packages/path_provider/path_provider_foundation/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 2.4.1
22

3+
* Updates to Pigeon v22.
34
* Updates minimum supported SDK version to Flutter 3.19/Dart 3.3.
45

56
## 2.4.0

0 commit comments

Comments
 (0)