registerMessageHandler method

void registerMessageHandler()

Registers the registrar's message handler (handlePlatformMessage) with the engine, so that plugin messages are correctly dispatched to the relevant registered plugin.

Only one handler can be registered at a time. Calling this method a second time silently unregisters any previously-registered handler and replaces it with the handler from this object.

This method uses a function called setPluginHandler in the dart:ui_web library. That function is only available when compiling for the web.

Implementation

void registerMessageHandler() {
  ui_web.setPluginHandler(handleFrameworkMessage);
}