Revert "Migrate to ChannelBuffers.push (#76288)" (#81226)

This reverts commit c26ed03c8a.
This commit is contained in:
Angjie Li
2021-04-26 12:57:17 -07:00
committed by GitHub
parent e2ddeb0427
commit b74df388e1
74 changed files with 596 additions and 889 deletions

View File

@@ -61,7 +61,7 @@ class Registrar extends BinaryMessenger {
/// the [dart:ui] library. That function is only available when
/// compiling for the web.
void registerMessageHandler() {
// The `ui.webOnlySetPluginHandler` function below is only defined in the Web dart:ui.
// The function below is only defined in the Web dart:ui.
// ignore: undefined_function
ui.webOnlySetPluginHandler(handleFrameworkMessage);
}
@@ -141,7 +141,7 @@ class Registrar extends BinaryMessenger {
@override
Future<ByteData?> send(String channel, ByteData? message) {
final Completer<ByteData?> completer = Completer<ByteData?>();
ui.channelBuffers.push(channel, message, (ByteData? reply) {
ui.window.onPlatformMessage!(channel, message, (ByteData? reply) {
try {
completer.complete(reply);
} catch (exception, stack) {
@@ -163,6 +163,26 @@ class Registrar extends BinaryMessenger {
else
_handlers[channel] = handler;
}
@override
bool checkMessageHandler(String channel, MessageHandler? handler) => _handlers[channel] == handler;
@override
void setMockMessageHandler(
String channel,
MessageHandler? handler,
) {
throw FlutterError(
'Setting mock handlers is not supported on the platform side.',
);
}
@override
bool checkMockMessageHandler(String channel, MessageHandler? handler) {
throw FlutterError(
'Setting mock handlers is not supported on the platform side.',
);
}
}
/// This class was previously separate from [Registrar] but was merged into it