-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[pigeon] Migrates off old BinaryMessenger API #3600
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
| // | ||
| // Autogenerated from Pigeon (v9.1.3), do not edit directly. | ||
| // Autogenerated from Pigeon (v9.1.4), 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 | ||
|
|
@@ -46,6 +46,8 @@ class _TestHostApiCodec extends StandardMessageCodec { | |
| /// | ||
| /// This comment also tests multiple line comments. | ||
| abstract class TestHostApi { | ||
| static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this being written once per class instead of at the file level?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Main motivation was to keep the generator script more readable by generating the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not as familiar with the test generator; that seems reasonable, so feel free to leave it. (Long term we want to do more to have shared utilities created in a clear, structured way, but that work may not have even started for this generator.) |
||
| TestDefaultBinaryMessengerBinding.instance; | ||
| static const MessageCodec<Object?> codec = _TestHostApiCodec(); | ||
|
|
||
| /// This comment is to test documentation comments. | ||
|
|
@@ -62,9 +64,12 @@ abstract class TestHostApi { | |
| 'dev.flutter.pigeon.MessageApi.initialize', codec, | ||
| binaryMessenger: binaryMessenger); | ||
| if (api == null) { | ||
| channel.setMockMessageHandler(null); | ||
| _testBinaryMessengerBinding!.defaultBinaryMessenger | ||
| .setMockDecodedMessageHandler<Object?>(channel, null); | ||
| } else { | ||
| channel.setMockMessageHandler((Object? message) async { | ||
| _testBinaryMessengerBinding!.defaultBinaryMessenger | ||
| .setMockDecodedMessageHandler<Object?>(channel, | ||
| (Object? message) async { | ||
| // ignore message | ||
| api.initialize(); | ||
| return <Object?>[]; | ||
|
|
@@ -76,9 +81,12 @@ abstract class TestHostApi { | |
| 'dev.flutter.pigeon.MessageApi.search', codec, | ||
| binaryMessenger: binaryMessenger); | ||
| if (api == null) { | ||
| channel.setMockMessageHandler(null); | ||
| _testBinaryMessengerBinding!.defaultBinaryMessenger | ||
| .setMockDecodedMessageHandler<Object?>(channel, null); | ||
| } else { | ||
| channel.setMockMessageHandler((Object? message) async { | ||
| _testBinaryMessengerBinding!.defaultBinaryMessenger | ||
| .setMockDecodedMessageHandler<Object?>(channel, | ||
| (Object? message) async { | ||
| assert(message != null, | ||
| 'Argument for dev.flutter.pigeon.MessageApi.search was null.'); | ||
| final List<Object?> args = (message as List<Object?>?)!; | ||
|
|
@@ -129,6 +137,8 @@ class _TestNestedApiCodec extends StandardMessageCodec { | |
|
|
||
| /// This comment is to test api documentation comments. | ||
| abstract class TestNestedApi { | ||
| static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => | ||
| TestDefaultBinaryMessengerBinding.instance; | ||
| static const MessageCodec<Object?> codec = _TestNestedApiCodec(); | ||
|
|
||
| /// This comment is to test method documentation comments. | ||
|
|
@@ -142,9 +152,12 @@ abstract class TestNestedApi { | |
| 'dev.flutter.pigeon.MessageNestedApi.search', codec, | ||
| binaryMessenger: binaryMessenger); | ||
| if (api == null) { | ||
| channel.setMockMessageHandler(null); | ||
| _testBinaryMessengerBinding!.defaultBinaryMessenger | ||
| .setMockDecodedMessageHandler<Object?>(channel, null); | ||
| } else { | ||
| channel.setMockMessageHandler((Object? message) async { | ||
| _testBinaryMessengerBinding!.defaultBinaryMessenger | ||
| .setMockDecodedMessageHandler<Object?>(channel, | ||
| (Object? message) async { | ||
| assert(message != null, | ||
| 'Argument for dev.flutter.pigeon.MessageNestedApi.search was null.'); | ||
| final List<Object?> args = (message as List<Object?>?)!; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the
!here the _ambiguate equivalent?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that plus typing the return type of the getter above as
TestDefaultBinaryMessengerBinding?to hide the fact thatTestDefaultBinaryMessengerBinding.instancemay be non-nullable in certain versions of Flutter.