Skip to content
WebView AllWebView All

Debugging

Debugging support is platform-specific because every engine exposes different tooling.

Enable WebView debugging globally:

await AndroidWebViewController.enableDebugging(true);

Use Chrome or Edge remote debugging tools to inspect the Android WebView.

Enable WebKit inspection per controller:

final webKit = controller.platform as WebKitWebViewController;
await webKit.setInspectable(true);

Inspection availability depends on the OS version and developer settings.

Open WebView2 DevTools:

final windows = controller.platform as WindowsWebViewController;
await windows.openDevTools();

The plugin disables user access to DevTools by default in all build modes. Enable the menu and keyboard entry points (including F12 and Ctrl+Shift+I) per controller when needed:

await windows.setDevToolsEnabled(true);

Apply this setting before loading content; runtime changes take effect on the next top-level navigation. It does not close existing DevTools or prevent the app from calling openDevTools() explicitly.

To allow user access only in debug builds, pass devToolsEnabled: kDebugMode to WindowsWebViewControllerCreationParams. Import kDebugMode from package:flutter/foundation.dart. Browser shortcuts must also be enabled for the DevTools shortcuts to work.

Check runtime availability:

final version = await WindowsWebViewController.getWebViewVersion();
debugPrint('WebView2 runtime: $version');

Enable WebKitGTK developer extras and open the inspector:

final linux = controller.platform as LinuxWebViewController;
await linux.setDeveloperExtrasEnabled(true);
await linux.openDevTools();

You can also set developerExtrasEnabled at creation time:

final params = const LinuxWebViewControllerCreationParams(
developerExtrasEnabled: true,
);
final controller = WebViewController.fromPlatformCreationParams(params);

Enable ArkWeb debugging globally:

await OhosWebViewController.enableDebugging(true);

Turn this on only for development builds unless your product policy explicitly allows WebView inspection.

Use browser DevTools. The WebView is an iframe with an ID such as webView0. Same-origin content can be inspected and manipulated directly. Cross-origin iframe internals are isolated by the browser.

All platforms can report page console messages when the engine exposes them:

await controller.setOnConsoleMessage((JavaScriptConsoleMessage message) {
debugPrint('[${message.level.name}] ${message.message}');
});

Console capture is useful for app telemetry, but avoid uploading sensitive page content without user consent.