sendNativeMessage method

Future<Map> sendNativeMessage(
  1. Object application,
  2. Map message
)

Send a single message to a native application. This method requires the "nativeMessaging" permission. application The name of the native messaging host, or target details. message The message that will be passed to the native messaging host.

Implementation

Future<Map> sendNativeMessage(
  Object application,
  Map message,
) async {
  var $res = await $js.chrome.runtime
      .sendNativeMessage(
        switch (application) {
          String() => application.toJS,
          NativeMessageTarget() => application.toJS,
          _ => throw UnsupportedError(
              'Received type: ${application.runtimeType}. Supported types are: String, NativeMessageTarget')
        },
        message.jsify()!,
      )
      .toDart;
  return $res.toDartMap();
}