onMessageReceived method

void onMessageReceived(
  1. JavaScriptMessage message
)

Implementation

void onMessageReceived(JavaScriptMessage message) {
  // debugPrint("Received message <=== \n ${message.message}");

  if (message.getMsgType() ==
      InboundMessageType.MAGIC_OVERLAY_READY.toShortString()) {
    widget._overlayReady = true;
    widget._dequeue();
  } else if (message.getMsgType() ==
      InboundMessageType.MAGIC_SHOW_OVERLAY.toShortString()) {
    setState(() {
      // setState can only be accessed in this context
      widget._isOverlayVisible = true;
    });
  } else if (message.getMsgType() ==
      InboundMessageType.MAGIC_HIDE_OVERLAY.toShortString()) {
    setState(() {
      widget._isOverlayVisible = false;
    });
  } else if (message.getMsgType() ==
      InboundMessageType.MAGIC_HANDLE_EVENT.toShortString()) {
    //Todo PromiseEvent
  } else if (message.getMsgType() ==
      InboundMessageType.MAGIC_HANDLE_RESPONSE.toShortString()) {
    widget.handleResponse(message);
  }
}