registerJavaScriptMessageHandler method

  1. @override
void registerJavaScriptMessageHandler(
  1. String name,
  2. JavaScriptMessageHandler handler
)
override

Install a message handler that you can call from your Javascript code.

available: macOS (10.10+)

Implementation

@override
void registerJavaScriptMessageHandler(
    String name, JavaScriptMessageHandler handler) {
  if (!Platform.isMacOS) {
    return;
  }
  assert(!_closed);
  if (_closed) {
    return;
  }
  assert(name.isNotEmpty);
  assert(!_javaScriptMessageHandlers.containsKey(name));
  _javaScriptMessageHandlers[name] = handler;
  channel.invokeMethod("registerJavaScripInterface", {
    "viewId": viewId,
    "name": name,
  });
}