Skip to content

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();

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.