void setJSONMessageHandler(String channel, Future handler(message))

Set a callback for receiving JSON messages from the platform.

Messages received are decoded as JSON before being passed to the given callback. The result of the callback is encoded as JSON before being returned as the response to the message.

The given callback will replace the currently registered callback (if any).

Source

static void setJSONMessageHandler(String channel, Future<dynamic> handler(dynamic message)) {
  setStringMessageHandler(channel, (String message) async {
    return _encodeJSON(await handler(_decodeJSON(message)));
  });
}