send method Null safety

  1. @override
Future<ByteData?> send(
  1. String channel,
  2. ByteData? message
)
override

Sends a platform message from the platform side back to the framework.

Implementation

@override
Future<ByteData?> send(String channel, ByteData? message) {
  final Completer<ByteData?> completer = Completer<ByteData?>();
  ui.channelBuffers.push(channel, message, (ByteData? reply) {
    try {
      completer.complete(reply);
    } catch (exception, stack) {
      FlutterError.reportError(FlutterErrorDetails(
        exception: exception,
        stack: stack,
        library: 'flutter web plugins',
        context: ErrorDescription('during a plugin-to-framework message'),
      ));
    }
  });
  return completer.future;
}