send method

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

Send a binary message to the platform plugins on the given channel.

Returns a Future which completes to the received response, undecoded, in binary form.

Implementation

@override
Future<ByteData?>? send(String channel, ByteData? message) {
  final MessageHandler? handler = _outboundHandlers[channel];
  Future<ByteData?>? result =
      handler == null ? delegate.send(channel, message) : handler(message);
  if (result != null) {
    _pendingMessages.add(result);
    result.catchError((Object error) {
      /* errors are the responsibility of the caller */
    }).whenComplete(() => _pendingMessages.remove(result));
  }
  return result;
}