Revert "Migrate to ChannelBuffers.push (#82057)" (#82525)

This commit is contained in:
Ian Hickson
2021-05-14 12:09:03 -07:00
committed by GitHub
parent 965671b8c8
commit 2ae1e39810
77 changed files with 736 additions and 1116 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