Migrating from flutter_inappwebview
zikzak_inappwebview is a community-driven, actively maintained fork of flutter_inappwebview that preserves the familiar WebView API surface while resolving over 156 upstream issues and modernizing platform support across Android, iOS, macOS, Windows, Linux, Web, and OpenHarmony. For beginners moving an existing application from flutter_inappwebview, most Dart widget and controller code works with a single import change, while a few specific JavaScript globals, platform requirements, and behavioral defaults require targeted updates.
Sources: README.md, zikzak_inappwebview/README.md
Step-by-Step Migration Flow
Section titled “Step-by-Step Migration Flow”Migrating an application involves updating package dependencies, replacing Dart imports, adjusting injected JavaScript calls to match the renamed bridge global, and verifying platform build requirements. The flowchart below illustrates the sequential steps you should follow in your Flutter project.
flowchart TD A[Update pubspec.yaml dependency] --> B[Run flutter pub get] B --> C[Replace Dart imports] C --> D{Does app use JS handlers?} D -- Yes --> E[Rename window.flutter_inappwebview to window.zikzak_inappwebview] D -- No --> F{Check platform & behavior changes} E --> F F --> G[Run flutter analyze & test on target platforms] G --> H[Migration Complete]Each stage builds on the previous one: dependency resolution makes the federated packages available, Dart import replacement wires your widgets to the new package barrel, JavaScript global renaming restores bidirectional bridge communication, and a final verification pass catches platform or behavioral edge cases.
Sources: README.md, zikzak_inappwebview/pubspec.yaml
Step 1: Update Dependencies and Package Imports
Section titled “Step 1: Update Dependencies and Package Imports”Start by opening your app’s pubspec.yaml and replacing flutter_inappwebview with zikzak_inappwebview: ^6.7.0, then run flutter pub get. Once resolved, replace every Dart import of package:flutter_inappwebview/flutter_inappwebview.dart with package:zikzak_inappwebview/zikzak_inappwebview.dart across your .dart files. The umbrella package re-exports the complete public API—including InAppWebView, InAppWebViewController, HeadlessInAppWebView, InAppBrowser, ChromeSafariBrowser, CookieManager, WebStorage, and all domain entities—so standard widget trees and controller calls compile without structural changes.
Sources: README.md, zikzak_inappwebview/lib/zikzak_inappwebview.dart, zikzak_inappwebview/lib/src/main.dart
Before and After Code Comparison
Section titled “Before and After Code Comparison”The table and code blocks below contrast the minimal Dart changes required for a basic inline WebView:
| Aspect | Upstream (flutter_inappwebview) |
Fork (zikzak_inappwebview) |
|---|---|---|
| Pubspec Dependency | flutter_inappwebview: ^6.x.x |
zikzak_inappwebview: ^6.7.0 |
| Dart Import | package:flutter_inappwebview/... |
package:zikzak_inappwebview/... |
| JS Bridge Global | window.flutter_inappwebview |
window.zikzak_inappwebview |
| Ready Event Name | flutterInAppWebViewPlatformReady |
flutterInAppWebViewPlatformReady (unchanged) |
| iOS/macOS Toolchain | CocoaPods / older Flutter | Swift Package Manager (SPM) / Flutter 3.50.0+ |
// BEFORE (flutter_inappwebview)import 'package:flutter_inappwebview/flutter_inappwebview.dart';
InAppWebView( initialUrlRequest: URLRequest(url: WebUri("https://flutter.dev")), onWebViewCreated: (controller) { controller.addJavaScriptHandler( handlerName: 'myHandler', callback: (args) => print('Received: $args'), ); },)
// AFTER (zikzak_inappwebview)import 'package:zikzak_inappwebview/zikzak_inappwebview.dart';
InAppWebView( initialUrlRequest: URLRequest(url: WebUri("https://flutter.dev")), onWebViewCreated: (controller) { controller.addJavaScriptHandler( handlerName: 'myHandler', callback: (args) => print('Received: $args'), ); },)Sources: README.md, zikzak_inappwebview/lib/src/in_app_webview/in_app_webview.dart
Step 2: Rename the JavaScript Bridge Global
Section titled “Step 2: Rename the JavaScript Bridge Global”The most important code-level breaking change when migrating from upstream is the JavaScript bridge global rename. In flutter_inappwebview, injected JavaScript calls Dart handlers through window.flutter_inappwebview.callHandler(...). In zikzak_inappwebview, the native layer on Android, iOS, macOS, and other platforms injects the bridge under window.zikzak_inappwebview. Because window.flutter_inappwebview is no longer defined, any HTML or JavaScript string that still calls window.flutter_inappwebview.callHandler(...) will throw a TypeError: Cannot read properties of undefined. Note that the readiness event dispatched by the native layer remains flutterInAppWebViewPlatformReady, so existing event listeners for bridge readiness continue to work unchanged.
Sources: README.md, zikzak_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart, zikzak_inappwebview_android/android/src/main/java/wtf/zikzak/zikzak_inappwebview_android/plugin_scripts_js/JavaScriptBridgeJS.java
// BEFORE (flutter_inappwebview)window.addEventListener("flutterInAppWebViewPlatformReady", function(event) { window.flutter_inappwebview.callHandler('saveData', { key: 'value' }) .then(function(result) { console.log("Saved:", result); });});
// AFTER (zikzak_inappwebview)window.addEventListener("flutterInAppWebViewPlatformReady", function(event) { window.zikzak_inappwebview.callHandler('saveData', { key: 'value' }) .then(function(result) { console.log("Saved:", result); });});If your Dart code injects JavaScript dynamically via evaluateJavascript or callAsyncJavaScript, apply the same find-and-replace (window.flutter_inappwebview → window.zikzak_inappwebview) inside those Dart string literals. For a deeper dive into handler registration and event wiring, see The JavaScript Bridge Global and Handler Wiring.
Sources: zikzak_inappwebview_platform_interface/lib/src/types/javascript_handler_callback.dart, zikzak_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart
Step 3: Verify Platform Requirements and Build Configuration
Section titled “Step 3: Verify Platform Requirements and Build Configuration”Upgrading the package version and Flutter SDK floor introduces platform toolchain changes that may affect local builds and CI pipelines. In particular, iOS and macOS now ship exclusively via Swift Package Manager (SPM) with raised OS minimums, Android requires API 24+, and Linux has transitioned from WebKitGTK to WPE WebKit 2.50+. Review the requirements table below against your development environment and deployment targets before running your first build.
| Platform | Upstream Minimum | zikzak_inappwebview Minimum |
Key Migration / Build Note |
|---|---|---|---|
| Flutter / Dart | Flutter 3.10+ / Dart 3.0+ | Flutter 3.50.0+ / Dart 3.13.0+ | Required for the iOS/macOS platform-view rendering fix (flutter/flutter#193363). |
| Android | API 19+ (KitKat) | API 24+ (Android 7.0 Nougat) | Uses pure Java (no Kotlin Gradle Plugin), AGP 8.5.2+, and 16 KB page-size support. |
| iOS | iOS 12.0+ (CocoaPods) | iOS 15.0+ (SPM only) | CocoaPods podspecs removed; uses Package.swift and Bundle.module storyboards. |
| macOS | macOS 10.13+ | macOS 12.0+ (SPM only) | Requires Swift Package Manager and full WKWebView feature parity. |
| Windows | Windows 10+ | Windows 10+ (WebView2 Runtime) | Pure Dart facade over WebView2 via zikzak_webview_windows (no C++ host build). |
| Linux | WebKitGTK 2.40+ | WPE WebKit 2.50+ | Re-based on WPE WebKit (wpe-webkit-2.0, wpe-platform-2.0, wpe-platform-headless-2.0). |
| Web | Any | Any (including WASM) | Supports dart2js and dart2wasm compilation. |
Sources: README.md, zikzak_inappwebview/pubspec.yaml, UPSTREAM_ISSUES_TRIAGE.md, zikzak_inappwebview/CHANGELOG.md
Step 4: Check Behavioral Changes and Default Value Shifts
Section titled “Step 4: Check Behavioral Changes and Default Value Shifts”While method signatures remain backward-compatible, the fork introduces new opt-in settings and changes specific defaults to improve security, stability, and multi-profile isolation. The table below summarizes the key behavioral differences a migrating developer should verify in their app.
| Area / API | Upstream Behavior | zikzak_inappwebview Behavior & Migration Action |
|---|---|---|
InAppWebViewSettings.dismissDialogues |
Defaulted to true (or unimplemented) |
Defaults to false (opt-in). Set dismissDialogues: true if you rely on automatic JS alert/confirm/prompt dismissal. |
InAppWebViewController Structure |
Monolithic controller class | Delegates to domain facades (controller.navigation, controller.javaScript, controller.cookies, controller.settings) while keeping top-level methods intact. |
Android dispose() Timers |
Called global pauseTimers() / onPause() |
Removed global timer pausing during dispose() to prevent cross-WebView hangs (#144); disposes own instance cleanly. |
| Android Cold-Start JS Bridge | Synchronous bridge registration | Deferred to View.post() so onWebViewCreated fires reliably on 100% of release cold starts (#2843). |
| iOS / macOS Passkeys (WebAuthn) | Limited / non-functional | Native PasskeyBridge enabled by default (passkeyBridgeEnabled: true). Set to false to opt out. |
| Console Interception | Always injected | Controlled by consoleLogEnabled (default true). Set false to disable console script injection. |
| Headless WebView Cap | Unbounded / native crash risk | Enforced process-wide cap via HeadlessInAppWebView.maxLiveWebViews (defaults: 3 on iOS/Android, 5 on macOS, 8 elsewhere). |
| iOS / macOS Persistent Data | Shared default store | Set persistentStoreIdentifier in InAppWebViewSettings for isolated, persistent WKWebsiteDataStore (iOS 17+ / macOS 14+). |
| Android File Provider Authority | ...flutter_inappwebview.fileprovider |
Renamed to zikzak_inappwebview_android.fileprovider if referenced in native Android XML/manifests. |
Sources: zikzak_inappwebview/CHANGELOG.md, zikzak_inappwebview/CHANGELOG.md, zikzak_inappwebview_platform_interface/lib/src/domain/entities/in_app_webview_settings/in_app_webview_settings.dart, zikzak_inappwebview/lib/src/in_app_webview/headless_in_app_webview.dart
Step 5: Explore New Capabilities Added in the Fork
Section titled “Step 5: Explore New Capabilities Added in the Fork”Beyond bug fixes, zikzak_inappwebview introduces pure-Dart and native modules that are not present in upstream flutter_inappwebview. Once your migration compiles cleanly, you can optionally adopt these built-in utilities directly from the main package import:
- Navigation Tracking & Session Recipes: Pure-Dart modules (
NavigationTrackerandRecipeRecorder/RecipeReplayer) for tracking client-side URL changes and recording/replaying DOM-driven user journeys, covered in Dialogue Dismisser and Navigation Tracking and Session Recording and Replay (Recipes). - Network Capture & Secret Redaction: Structured interception of
XMLHttpRequestandfetchcalls with automatic redaction of auth-shaped secrets, detailed in Network Capture, Interception, and Secret Redaction. - Portable Webview Sessions: Save and restore cookies and
localStorageacross app restarts viaWebViewSessionsandzuraffa_session, documented in Cookies, Web Storage, and Credential Management. - Optional Value-Add Module (
zikzak_inappwebview_module): For advanced multi-tab pooling, VCR cassettes, and agent tooling, see VCR Cassettes and the WebView Pool and Monorepo Layout and the Federated Plugin Model.
Sources: zikzak_inappwebview/lib/src/main.dart, zikzak_inappwebview/lib/src/webview_sessions/webview_sessions.dart, CONSUMER_TRANSITION_PLAN.md
Troubleshooting Common Migration Issues
Section titled “Troubleshooting Common Migration Issues”If your application encounters errors after switching packages, consult the diagnostic table below to pinpoint the root cause and apply the corresponding fix.
| Symptom / Error Message | Root Cause | Resolution |
|---|---|---|
TypeError: window.flutter_inappwebview.callHandler is not a function |
Injected JS still references the old upstream global name. | Replace window.flutter_inappwebview with window.zikzak_inappwebview in all HTML/JS strings. |
Could not find a storyboard named 'WebView' (iOS) |
Legacy bundle lookup from pre-SPM migration. | Ensure your project uses Flutter 3.50.0+ and resolves zikzak_inappwebview_ios via SPM (Bundle.module). |
MissingPluginException on Headless WebView (Linux/macOS) |
Calling loadUrl before off-screen renderer finishes first paint. |
Await headlessWebView.run() (which now waits for first render) before invoking loadUrl. |
StateError: maxLiveWebViews must be set before the first headless run() |
Attempting to change the headless cap while instances are active. | Set HeadlessInAppWebView.maxLiveWebViews in main() before any run() call. |
Native file chooser crash on Android (CVE-2020-6563) |
Upstream vulnerability in file:// picker handling. |
Upgraded automatically in zikzak_inappwebview; ensure no custom native override bypasses sandbox checks. |
Sources: zikzak_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart, zikzak_inappwebview/CHANGELOG.md, zikzak_inappwebview/lib/src/in_app_webview/headless_in_app_webview.dart, UPSTREAM_ISSUES_TRIAGE.md
Next Steps in the Documentation
Section titled “Next Steps in the Documentation”Now that you have migrated your codebase to zikzak_inappwebview, continue through the Get Started catalog to familiarize yourself with the fork’s architecture and APIs:
- The JavaScript Bridge Global and Handler Wiring — Master bidirectional communication and promise-based responses across platforms.
- Example App and Screen-by-Screen Walkthrough — Explore the bundled example app to see live demonstrations of every feature.
- InAppWebView Widget and InAppWebViewController — Dive into widget parameters, event callbacks, and domain controller facades.
- Disposal Lifecycle and KeepAlive Patterns — Learn the standardized disposal patterns and
KeepAlivecaching behavior in the fork.