Skip to content

iOS and macOS

iOS and macOS are provided by webview_flutter_wkwebview ^3.25.0. webview_all registers it as the default implementation for both Apple platforms.

Item Value
Package webview_flutter_wkwebview
Main platform class WebKitWebViewPlatform
Controller WebKitWebViewController
Widget WebKitWebViewWidget
Navigation delegate WebKitNavigationDelegate
Cookie manager WebKitWebViewCookieManager
Engine WKWebView
Minimum iOS 13.0+
Minimum macOS 10.15+
final params = WebKitWebViewControllerCreationParams(
allowsInlineMediaPlayback: true,
mediaTypesRequiringUserAction: const <PlaybackMediaTypes>{},
limitsNavigationsToAppBoundDomains: false,
javaScriptCanOpenWindowsAutomatically: true,
);
final controller = WebViewController.fromPlatformCreationParams(params);
Param Meaning
mediaTypesRequiringUserAction Set of PlaybackMediaTypes.audio and PlaybackMediaTypes.video that require user gesture. Empty set allows autoplay.
allowsInlineMediaPlayback Allows inline HTML5 video playback instead of fullscreen-only playback.
limitsNavigationsToAppBoundDomains Enables App-Bound Domains on supported iOS versions.
javaScriptCanOpenWindowsAutomatically Controls JavaScript popup permission. null uses the native default.
API Purpose
setAllowsBackForwardNavigationGestures(bool enabled) Enables swipe navigation gestures.
setAllowsLinkPreview(bool allow) Enables or disables link previews where supported.
setOnCanGoBackChange(callback) Receives canGoBack state changes.
setInspectable(bool inspectable) Enables WebKit inspection on OS versions that support it.
loadFileWithParams(WebKitLoadFileParams params) Loads a local file with an explicit read access scope.
await (controller.platform as WebKitWebViewController).loadFileWithParams(
WebKitLoadFileParams(
absoluteFilePath: '/Users/me/site/index.html',
readAccessPath: '/Users/me/site',
),
);

readAccessPath must include any local resources referenced by the loaded page.

Use WebKitJavaScriptChannelParams when constructing platform-specific channel params directly:

await controller.platform.addJavaScriptChannel(
WebKitJavaScriptChannelParams(
name: 'Host',
onMessageReceived: (JavaScriptMessage message) {},
),
);

The common WebViewController.addJavaScriptChannel automatically converts common params to WebKit params.

WebKitWebViewPermissionRequest supports:

Method Meaning
grant() Approves the resource request.
deny() Denies the resource request.
prompt() Lets the system prompt the user where supported.

Your app still needs the corresponding Info.plist privacy description keys.

The same Dart package targets iOS and macOS, but some underlying WebKit wrappers are UIKit-specific. Current macOS limitations include:

Area macOS limit
Scroll view access Some scroll view methods are not implemented by the platform wrapper on macOS.
Background color/opacity Some UIKit properties such as background color and opaque may not be implemented on macOS.
Link preview Availability depends on platform support.

For cross-platform Apple code, keep these calls behind platform checks and treat UnimplementedError as a signal that the native property has no macOS bridge.

  • WebKit may reject JavaScript return values that cannot be bridged to Dart.
  • App-Bound Domains require host app configuration and supported iOS versions.
  • Permission handling still depends on OS privacy entitlements and user decisions.