WebViewAndroidPlatformController constructor

WebViewAndroidPlatformController({
  1. required bool useHybridComposition,
  2. required CreationParams creationParams,
  3. required WebViewPlatformCallbacksHandler callbacksHandler,
  4. required JavascriptChannelRegistry javascriptChannelRegistry,
  5. @visibleForTesting WebViewProxy webViewProxy = const WebViewProxy(),
  6. @visibleForTesting FlutterAssetManager flutterAssetManager = const android_webview.FlutterAssetManager(),
  7. @visibleForTesting WebStorage? webStorage,
})

Implementation

WebViewAndroidPlatformController({
  required bool useHybridComposition,
  required CreationParams creationParams,
  required this.callbacksHandler,
  required this.javascriptChannelRegistry,
  @visibleForTesting this.webViewProxy = const WebViewProxy(),
  @visibleForTesting
      this.flutterAssetManager = const android_webview.FlutterAssetManager(),
  @visibleForTesting android_webview.WebStorage? webStorage,
})  : webStorage = webStorage ?? android_webview.WebStorage.instance,
      assert(creationParams.webSettings?.hasNavigationDelegate != null),
      super(callbacksHandler) {
  webView = webViewProxy.createWebView(
    useHybridComposition: useHybridComposition,
  );

  webView.settings.setDomStorageEnabled(true);
  webView.settings.setJavaScriptCanOpenWindowsAutomatically(true);
  webView.settings.setSupportMultipleWindows(true);
  webView.settings.setLoadWithOverviewMode(true);
  webView.settings.setUseWideViewPort(true);
  webView.settings.setDisplayZoomControls(false);
  webView.settings.setBuiltInZoomControls(true);

  _setCreationParams(creationParams);
  webView.setDownloadListener(downloadListener);
  webView.setWebChromeClient(webChromeClient);

  final String? initialUrl = creationParams.initialUrl;
  if (initialUrl != null) {
    loadUrl(initialUrl, <String, String>{});
  }
}