Future<Null> handlePlatformMessage(String channel, ByteData data, PlatformMessageResponseCallback callback)

Calls the handler registered for the given channel.

Typically called by ServicesBinding to handle platform messages received from ui.window.onPlatformMessage.

To register a handler for a given message channel, see setStringMessageHandler and setJSONMessageHandler.

Source

static Future<Null> handlePlatformMessage(
      String channel, ByteData data, ui.PlatformMessageResponseCallback callback) async {
  ByteData response;
  try {
    _PlatformMessageHandler handler = _handlers[channel];
    if (handler != null)
      response = await handler(data);
  } catch (exception, stack) {
    FlutterError.reportError(new FlutterErrorDetails(
      exception: exception,
      stack: stack,
      library: 'services library',
      context: 'during a platform message callback',
    ));
  } finally {
    callback(response);
  }
}