InAppWebViewWebElement constructor

InAppWebViewWebElement({
  1. required dynamic viewId,
  2. required BinaryMessenger messenger,
})

Implementation

InAppWebViewWebElement(
    {required dynamic viewId, required BinaryMessenger messenger}) {
  this._viewId = viewId;
  this._messenger = messenger;
  iframeContainer = DivElement()
    ..id = 'flutter_adeeinappwebview-$_viewId-container'
    ..style.height = '100%'
    ..style.width = '100%'
    ..style.border = 'none';
  iframe = IFrameElement()
    ..id = 'flutter_adeeinappwebview-$_viewId'
    ..style.height = '100%'
    ..style.width = '100%'
    ..style.border = 'none';
  iframeContainer.append(iframe);

  _channel = MethodChannel(
    'ai.adee/flutter_adeeinappwebview_$_viewId',
    const StandardMethodCodec(),
    _messenger,
  );

  this._channel?.setMethodCallHandler((call) async {
    try {
      return await handleMethodCall(call);
    } on Error catch (e) {
      print(e);
      print(e.stackTrace);
    }
  });

  bridgeJsObject = js.JsObject.fromBrowserObject(
      js.context[WebPlatformManager.BRIDGE_JS_OBJECT_NAME]);
  bridgeJsObject['webViews'][_viewId] = bridgeJsObject
      .callMethod("createFlutterInAppWebView", [_viewId, iframe.id]);
}