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 = HTMLDivElement()
    ..id = 'flutter_inappwebview-$_viewId-container'
    ..style.height = '100%'
    ..style.width = '100%'
    ..style.border = 'none';
  iframe = HTMLIFrameElement()
    ..id = 'flutter_inappwebview-$_viewId'
    ..style.height = '100%'
    ..style.width = '100%'
    ..style.border = 'none';
  iframeContainer.append(iframe);

  _channel = MethodChannel(
    'com.pichillilorenzo/flutter_inappwebview_$_viewId',
    const StandardMethodCodec(),
    _messenger,
  );

  this._channel?.setMethodCallHandler((call) async {
    try {
      return await handleMethodCall(call);
    } on Error catch (e) {
      log(e.toString(),
          name: runtimeType.toString(), error: e, stackTrace: e.stackTrace);
    }
  });

  jsWebView = flutterInAppWebView?.createFlutterInAppWebView(
      _viewId, iframe, iframeContainer);
}