setMessageHandler method

void setMessageHandler (String channel, Future<ByteData> handler(ByteData message))

Set a callback for receiving messages from the platform plugins on the given channel, without decoding them.

The given callback will replace the currently registered callback for that channel, if any. To remove the handler, pass null as the handler argument.

The handler's return value, if non-null, is sent as a response, unencoded.

Implementation

static void setMessageHandler(String channel, Future<ByteData> handler(ByteData message)) {
  if (handler == null)
    _handlers.remove(channel);
  else
    _handlers[channel] = handler;
}