sendMessage method

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

Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The runtime.onMessage event is fired in each content script running in the specified tab for the current extension. message The message to send. This message should be a JSON-ifiable object.

Implementation

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