WebViewController.fromPlatformCreationParams constructor
- PlatformWebViewControllerCreationParams params, {
- void onPermissionRequest(
- WebViewPermissionRequest request
Constructs a WebViewController from creation params for a specific platform.
onPermissionRequest
: A callback that notifies the host application that
web content is requesting permission to access the specified resources.
To grant access for a device resource, most platforms will need to update
their app configurations for the relevant system resource.
For Android, you will need to update your AndroidManifest.xml
. See
https://developer.android.com/training/permissions/declaring
For iOS, you will need to update your Info.plist
. See
https://developer.apple.com/documentation/uikit/protecting_the_user_s_privacy/requesting_access_to_protected_resources?language=objc.
Below is an example of setting platform-specific creation parameters for iOS and Android:
PlatformWebViewControllerCreationParams params =
const PlatformWebViewControllerCreationParams();
if (WebViewPlatform.instance is WebKitWebViewPlatform) {
params = WebKitWebViewControllerCreationParams
.fromPlatformWebViewControllerCreationParams(
params,
);
} else if (WebViewPlatform.instance is AndroidWebViewPlatform) {
params = AndroidWebViewControllerCreationParams
.fromPlatformWebViewControllerCreationParams(
params,
);
}
final WebViewController webViewController =
WebViewController.fromPlatformCreationParams(
params,
);
Implementation
WebViewController.fromPlatformCreationParams(
PlatformWebViewControllerCreationParams params, {
void Function(WebViewPermissionRequest request)? onPermissionRequest,
}) : this.fromPlatform(
PlatformWebViewController(params),
onPermissionRequest: onPermissionRequest,
);