WebViewWidget.fromPlatformCreationParams constructor

WebViewWidget.fromPlatformCreationParams({
  1. Key? key,
  2. required PlatformWebViewWidgetCreationParams params,
})

Constructs a WebViewWidget from creation params for a specific platform.

Below is an example of setting platform-specific creation parameters for iOS and Android:

final WebViewController controller = WebViewController();

PlatformWebViewWidgetCreationParams params =
    PlatformWebViewWidgetCreationParams(
  controller: controller.platform,
  layoutDirection: TextDirection.ltr,
  gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
);

if (WebViewPlatform.instance is WebKitWebViewPlatform) {
  params = WebKitWebViewWidgetCreationParams
      .fromPlatformWebViewWidgetCreationParams(
    params,
  );
} else if (WebViewPlatform.instance is AndroidWebViewPlatform) {
  params = AndroidWebViewWidgetCreationParams
      .fromPlatformWebViewWidgetCreationParams(
    params,
  );
}

final WebViewWidget webViewWidget =
    WebViewWidget.fromPlatformCreationParams(
  params: params,
);

Implementation

WebViewWidget.fromPlatformCreationParams({
  Key? key,
  required PlatformWebViewWidgetCreationParams params,
}) : this.fromPlatform(key: key, platform: PlatformWebViewWidget(params));