Update `platform_channels` for 3.10 (#1902)

Replaces deprecated APIs in unit tests.

Fixes https://github.com/flutter/samples/issues/1765

## Pre-launch Checklist

- [x] I read the [Flutter Style Guide] _recently_, and have followed its
advice.
- [x] I signed the [CLA].
- [x] I read the [Contributors Guide].
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] All existing and new tests are passing.

<!-- Links -->
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[CLA]: https://cla.developers.google.com/
[Discord]: https://github.com/flutter/flutter/wiki/Chat
[Contributors Guide]:
https://github.com/flutter/samples/blob/main/CONTRIBUTING.md
pull/1903/head
stuartmorgan 1 year ago committed by GitHub
parent bce29a0ff2
commit b7541dd49f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -20,7 +20,8 @@ void main() {
// and add the incoming message to the StreamController used by the EventChannel
// after decoding the message with codec used by the EventChannel.
void emitValues(ByteData? event) {
ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage(
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.handlePlatformMessage(
'eventChannelDemo',
event,
(reply) {},
@ -29,7 +30,8 @@ void main() {
// Register a mock for EventChannel. EventChannel under the hood uses
// MethodChannel to listen and cancel the created stream.
ServicesBinding.instance.defaultBinaryMessenger
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMessageHandler('eventChannelDemo', (message) async {
// Decode the message into MethodCallHandler.
final methodCall = standardMethod.decodeMethodCall(message);

@ -26,15 +26,18 @@ void main() {
setUpAll(() {
// Mock for the pet list received from the platform.
basicMessageChannel.setMockMessageHandler((message) async {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockDecodedMessageHandler(basicMessageChannel, (message) async {
petListModel = PetListModel.fromJson(message!);
return null;
});
// Mock for the index received from the Dart to delete the pet details,
// and send the updated pet list back to Dart.
const BasicMessageChannel<ByteData?>('binaryCodecDemo', BinaryCodec())
.setMockMessageHandler((message) async {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockDecodedMessageHandler(
const BasicMessageChannel<ByteData?>(
'binaryCodecDemo', BinaryCodec()), (message) async {
// Convert the ByteData to String.
final index = utf8.decoder.convert(message!.buffer
.asUint8List(message.offsetInBytes, message.lengthInBytes));

Loading…
Cancel
Save