push method Null safety

void push(
  1. String name,
  2. ByteData? data,
  3. PlatformMessageResponseCallback callback
)

Adds a message (data) to the named channel buffer (name).

The callback argument is a closure that, when called, will send messages back to the plugin.

If a message overflows the channel, and the channel has not been configured to expect overflow, then, in debug mode, a message will be printed to the console warning about the overflow.

Implementation

void push(String name, ByteData? data, PlatformMessageResponseCallback callback) {
  final _Channel channel = _channels.putIfAbsent(name, () => _Channel());
  if (channel.push(_StoredMessage(data, callback))) {
    _printDebug(
      'A message on the $name channel was discarded before it could be handled.\n'
      'This happens when a plugin sends messages to the framework side before the '
      'framework has had an opportunity to register a listener. See the ChannelBuffers '
      'API documentation for details on how to configure the channel to expect more '
      'messages, or to expect messages to get discarded:\n'
      '  https://api.flutter.cn/flutter/dart-ui/ChannelBuffers-class.html'
    );
  }
}