sendMessage method

Future<Object> sendMessage(
  1. String? extensionId,
  2. Object message,
  3. SendMessageOptions? options
)

Sends a single message to event listeners within your extension/app or a different extension/app. Similar to runtime.connect but only sends a single message, with an optional response. If sending to your extension, the runtime.onMessage event will be fired in every frame of your extension (except for the sender's frame), or runtime.onMessageExternal, if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use tabs.sendMessage. extensionId The ID of the extension/app to send the message to. If omitted, the message will be sent to your own extension/app. Required if sending messages from a web page for web messaging. message The message to send. This message should be a JSON-ifiable object.

Implementation

Future<Object> sendMessage(
  String? extensionId,
  Object message,
  SendMessageOptions? options,
) async {
  var $res = await promiseToFuture<JSAny>($js.chrome.runtime.sendMessage(
    extensionId,
    message.jsify()!,
    options?.toJS,
  ));
  return $res.dartify()!;
}