Skip to content

Commit d29ad29

Browse files
[file_selector] Update Pigeon in Android implementation (#10126)
Updates `file_selector_android` to Pigeon 26.x. Fixes a latent bug in pigeons/file_selector_api.dart; it had a class that was marked as `implements Exception`; in older versions of Pigeon this was ignored, so was a no-op, but in current versions it triggers the very limited subclassing support, which doesn't allow inheriting from outside the interface definition, and thus generates incorrect code. ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent c7a25fa commit d29ad29

File tree

5 files changed

+103
-14
lines changed

5 files changed

+103
-14
lines changed

packages/file_selector/file_selector_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.1+17
2+
3+
* Updates Pigeon to 26.x.
4+
15
## 0.5.1+16
26

37
* Bumps com.android.tools.build:gradle to 8.12.1.

packages/file_selector/file_selector_android/android/src/main/java/dev/flutter/packages/file_selector_android/GeneratedFileSelectorApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2013 The Flutter Authors
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 (v22.6.2), do not edit directly.
4+
// Autogenerated from Pigeon (v26.0.1), do not edit directly.
55
// See also: https://pub.dev/packages/pigeon
66

77
package dev.flutter.packages.file_selector_android;

packages/file_selector/file_selector_android/lib/src/file_selector_api.g.dart

Lines changed: 95 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2013 The Flutter Authors
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 (v22.6.2), do not edit directly.
4+
// Autogenerated from Pigeon (v26.0.1), do not edit directly.
55
// See also: https://pub.dev/packages/pigeon
66
// 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

@@ -18,6 +18,24 @@ PlatformException _createConnectionError(String channelName) {
1818
);
1919
}
2020

21+
bool _deepEquals(Object? a, Object? b) {
22+
if (a is List && b is List) {
23+
return a.length == b.length &&
24+
a.indexed.every(
25+
((int, dynamic) item) => _deepEquals(item.$2, b[item.$1]),
26+
);
27+
}
28+
if (a is Map && b is Map) {
29+
return a.length == b.length &&
30+
a.entries.every(
31+
(MapEntry<Object?, Object?> entry) =>
32+
(b as Map<Object?, Object?>).containsKey(entry.key) &&
33+
_deepEquals(entry.value, b[entry.key]),
34+
);
35+
}
36+
return a == b;
37+
}
38+
2139
enum FileSelectorExceptionCode {
2240
securityException,
2341
ioException,
@@ -35,17 +53,38 @@ class FileSelectorNativeException {
3553

3654
String message;
3755

38-
Object encode() {
56+
List<Object?> _toList() {
3957
return <Object?>[fileSelectorExceptionCode, message];
4058
}
4159

60+
Object encode() {
61+
return _toList();
62+
}
63+
4264
static FileSelectorNativeException decode(Object result) {
4365
result as List<Object?>;
4466
return FileSelectorNativeException(
4567
fileSelectorExceptionCode: result[0]! as FileSelectorExceptionCode,
4668
message: result[1]! as String,
4769
);
4870
}
71+
72+
@override
73+
// ignore: avoid_equals_and_hash_code_on_mutable_classes
74+
bool operator ==(Object other) {
75+
if (other is! FileSelectorNativeException ||
76+
other.runtimeType != runtimeType) {
77+
return false;
78+
}
79+
if (identical(this, other)) {
80+
return true;
81+
}
82+
return _deepEquals(encode(), other.encode());
83+
}
84+
85+
@override
86+
// ignore: avoid_equals_and_hash_code_on_mutable_classes
87+
int get hashCode => Object.hashAll(_toList());
4988
}
5089

5190
class FileResponse {
@@ -70,7 +109,7 @@ class FileResponse {
70109

71110
FileSelectorNativeException? fileSelectorNativeException;
72111

73-
Object encode() {
112+
List<Object?> _toList() {
74113
return <Object?>[
75114
path,
76115
mimeType,
@@ -81,6 +120,10 @@ class FileResponse {
81120
];
82121
}
83122

123+
Object encode() {
124+
return _toList();
125+
}
126+
84127
static FileResponse decode(Object result) {
85128
result as List<Object?>;
86129
return FileResponse(
@@ -92,6 +135,22 @@ class FileResponse {
92135
fileSelectorNativeException: result[5] as FileSelectorNativeException?,
93136
);
94137
}
138+
139+
@override
140+
// ignore: avoid_equals_and_hash_code_on_mutable_classes
141+
bool operator ==(Object other) {
142+
if (other is! FileResponse || other.runtimeType != runtimeType) {
143+
return false;
144+
}
145+
if (identical(this, other)) {
146+
return true;
147+
}
148+
return _deepEquals(encode(), other.encode());
149+
}
150+
151+
@override
152+
// ignore: avoid_equals_and_hash_code_on_mutable_classes
153+
int get hashCode => Object.hashAll(_toList());
95154
}
96155

97156
class FileTypes {
@@ -101,17 +160,37 @@ class FileTypes {
101160

102161
List<String> extensions;
103162

104-
Object encode() {
163+
List<Object?> _toList() {
105164
return <Object?>[mimeTypes, extensions];
106165
}
107166

167+
Object encode() {
168+
return _toList();
169+
}
170+
108171
static FileTypes decode(Object result) {
109172
result as List<Object?>;
110173
return FileTypes(
111174
mimeTypes: (result[0] as List<Object?>?)!.cast<String>(),
112175
extensions: (result[1] as List<Object?>?)!.cast<String>(),
113176
);
114177
}
178+
179+
@override
180+
// ignore: avoid_equals_and_hash_code_on_mutable_classes
181+
bool operator ==(Object other) {
182+
if (other is! FileTypes || other.runtimeType != runtimeType) {
183+
return false;
184+
}
185+
if (identical(this, other)) {
186+
return true;
187+
}
188+
return _deepEquals(encode(), other.encode());
189+
}
190+
191+
@override
192+
// ignore: avoid_equals_and_hash_code_on_mutable_classes
193+
int get hashCode => Object.hashAll(_toList());
115194
}
116195

117196
class _PigeonCodec extends StandardMessageCodec {
@@ -188,9 +267,11 @@ class FileSelectorApi {
188267
pigeonChannelCodec,
189268
binaryMessenger: pigeonVar_binaryMessenger,
190269
);
270+
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
271+
<Object?>[initialDirectory, allowedTypes],
272+
);
191273
final List<Object?>? pigeonVar_replyList =
192-
await pigeonVar_channel.send(<Object?>[initialDirectory, allowedTypes])
193-
as List<Object?>?;
274+
await pigeonVar_sendFuture as List<Object?>?;
194275
if (pigeonVar_replyList == null) {
195276
throw _createConnectionError(pigeonVar_channelName);
196277
} else if (pigeonVar_replyList.length > 1) {
@@ -218,9 +299,11 @@ class FileSelectorApi {
218299
pigeonChannelCodec,
219300
binaryMessenger: pigeonVar_binaryMessenger,
220301
);
302+
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
303+
<Object?>[initialDirectory, allowedTypes],
304+
);
221305
final List<Object?>? pigeonVar_replyList =
222-
await pigeonVar_channel.send(<Object?>[initialDirectory, allowedTypes])
223-
as List<Object?>?;
306+
await pigeonVar_sendFuture as List<Object?>?;
224307
if (pigeonVar_replyList == null) {
225308
throw _createConnectionError(pigeonVar_channelName);
226309
} else if (pigeonVar_replyList.length > 1) {
@@ -251,9 +334,11 @@ class FileSelectorApi {
251334
pigeonChannelCodec,
252335
binaryMessenger: pigeonVar_binaryMessenger,
253336
);
337+
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
338+
<Object?>[initialDirectory],
339+
);
254340
final List<Object?>? pigeonVar_replyList =
255-
await pigeonVar_channel.send(<Object?>[initialDirectory])
256-
as List<Object?>?;
341+
await pigeonVar_sendFuture as List<Object?>?;
257342
if (pigeonVar_replyList == null) {
258343
throw _createConnectionError(pigeonVar_channelName);
259344
} else if (pigeonVar_replyList.length > 1) {

packages/file_selector/file_selector_android/pigeons/file_selector_api.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ enum FileSelectorExceptionCode {
2323
illegalStateException, //unused
2424
}
2525

26-
class FileSelectorNativeException implements Exception {
26+
class FileSelectorNativeException {
2727
late final FileSelectorExceptionCode fileSelectorExceptionCode;
2828
late final String message;
2929
}

packages/file_selector/file_selector_android/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: file_selector_android
22
description: Android implementation of the file_selector package.
33
repository: https://github.com/flutter/packages/tree/main/packages/file_selector/file_selector_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
5-
version: 0.5.1+16
5+
version: 0.5.1+17
66

77
environment:
88
sdk: ^3.7.0
@@ -28,7 +28,7 @@ dev_dependencies:
2828
flutter_test:
2929
sdk: flutter
3030
mockito: ^5.4.4
31-
pigeon: ^22.4.2
31+
pigeon: ^26.0.1
3232

3333
topics:
3434
- files

0 commit comments

Comments
 (0)