Skip to content

Monorepo Layout and the Federated Plugin Model

This page explains the physical and logical shape of the zikzak_inappwebview repository: why a single Flutter plugin is delivered as a set of independently versioned pub packages, how those packages are wired into one federated plugin by the Flutter tooling, and how a second, internal federation — the core/module two-tier split — layers an intelligence tier on top of the raw platform plumbing. Everything here is derived from the manifests and gate scripts in the repository, so the layout you read is the layout the build actually enforces.

A federated plugin is Flutter’s mechanism for splitting one plugin into an app-facing package plus one implementation package per platform, each published separately and selected at build time by the tool rather than by conditional imports in a single codebase. This repository uses that mechanism as its primary architectural boundary: the umbrella package declares the platforms it supports and names a default_package for each, while every implementation package declares implements: zikzak_inappwebview and is therefore treated by pub as a federated implementation of the umbrella’s plugin interface rather than as an independent plugin. The consequence is that a consumer adds exactly one dependency and receives only the platform code their build target requires; the Android Java sources never enter an iOS build, and the Windows facade never enters a Linux build.

graph TD
APP["Consumer app"] --> UMB["zikzak_inappwebview<br/>umbrella / app-facing"]
UMB --> PI["zikzak_inappwebview_platform_interface<br/>contract + entity models"]
UMB -. default_package .-> AND["zikzak_inappwebview_android"]
UMB -. default_package .-> IOS["zikzak_inappwebview_ios"]
UMB -. default_package .-> MAC["zikzak_inappwebview_macos"]
UMB -. default_package .-> WEB["zikzak_inappwebview_web"]
UMB -. default_package .-> WIN["zikzak_inappwebview_windows"]
UMB -. default_package .-> LIN["zikzak_inappwebview_linux"]
AND --> PI
IOS --> PI
MAC --> PI
WEB --> PI
WIN --> PI
LIN --> PI
WIN --> FORK["zikzak_webview_windows<br/>WebView2 + DevTools fork"]
OHOS["zikzak_inappwebview_ohos<br/>implements, not registered"] -.-> PI
MOD["zikzak_inappwebview_module<br/>publish_to: none"] --> UMB

Solid arrows are declared pub dependencies; dotted arrows are the federated default_package selection, which is a build-time relationship rather than a pub dependency edge. The diagram makes the two structural facts visible at once: all platform packages converge on the platform interface, and the umbrella is the only package the consumer touches.

Sources: pubspec.yaml, pubspec.yaml

The repository root holds eleven package directories. They are not peers in role: one is the contract, one is the app-facing surface, six are registered platform implementations, and the remainder are a fork, an unregistered implementation, and a non-published module. The table below records each package’s declared role, whether it carries native code, and whether the publish script manages its version.

Package Role in the federation Native code In publish set
zikzak_inappwebview Umbrella; public barrel + widgets/controllers No Yes
zikzak_inappwebview_platform_interface Contract seam + Zorphy entity models No Yes
zikzak_inappwebview_android Android implementation Java/Kotlin under android/ Yes
zikzak_inappwebview_ios iOS implementation Swift (SPM) Yes
zikzak_inappwebview_macos macOS implementation Swift (SPM) Yes
zikzak_inappwebview_linux Linux implementation C++ over WPE WebKit Yes
zikzak_inappwebview_windows Windows facade over the fork No (Dart facade) Yes
zikzak_inappwebview_web Web implementation No (dart:js_interop) Yes
zikzak_webview_windows WebView2 + DevTools protocol fork C++ No
zikzak_inappwebview_ohos OpenHarmony/ArkWeb implementation ArkTS under ohos/ No
zikzak_inappwebview_module Intelligence tier (dev only) No No (publish_to: none)

Two entries deserve emphasis because they break the otherwise uniform pattern. zikzak_inappwebview_windows is a pure Dart facade: it declares a dartPluginClass and no native plugin class of its own, delegating all native work to zikzak_webview_windows, which is a renamed fork of webview_windows 0.4.0 carrying an additional DevTools protocol API. And zikzak_inappwebview_module is the only package that is explicitly not publishable, which is what allows it to depend on sibling checkouts by path without any risk of leaking those paths to a consumer.

Sources: pubspec.yaml, pubspec.yaml, pubspec.yaml

The Umbrella Seam: default_package and implements

Section titled “The Umbrella Seam: default_package and implements”

The federation is not a convention; it is two manifest fields that must agree. The umbrella enumerates each supported platform and names the package that supplies it, and each implementation mirrors that with implements: zikzak_inappwebview plus a pluginClass (the native entry point) and, where a Dart-side registration exists, a dartPluginClass (the Dart class that registers the platform interface instance). The pairing is mechanical and one-to-one:

Platform default_package pluginClass dartPluginClass
android zikzak_inappwebview_android InAppWebViewFlutterPlugin AndroidInAppWebViewPlatform
ios zikzak_inappwebview_ios InAppWebViewFlutterPlugin IOSInAppWebViewPlatform
macos zikzak_inappwebview_macos InAppWebViewFlutterPlugin MacOSInAppWebViewPlatform
linux zikzak_inappwebview_linux InAppWebViewFlutterPlugin LinuxInAppWebViewPlatform
windows zikzak_inappwebview_windows — (web plugin, fileName) ZikzakInAppWebViewWindows
web zikzak_inappwebview_web — (fileName: …_web.dart) —

The repeated InAppWebViewFlutterPlugin native class name across four packages is not duplication by accident: each lives in a different language and a different package namespace, so the Flutter tool disambiguates them by package. On Android the class is additionally qualified by a Java package, wtf.zikzak.zikzak_inappwebview_android, which is the value the native registration looks up. The web and Windows entries substitute a fileName for a native class because their registration is Dart-side, which is the shape a federated implementation takes when no platform channel is needed at registration time.

Sources: pubspec.yaml, pubspec.yaml, pubspec.yaml, pubspec.yaml

The receiving end of this seam is a single abstract registry. InAppWebViewPlatform extends plugin_platform_interface’s PlatformInterface with a private token, holds a static instance, and verifies the token on assignment so that only a class from the contract package can be installed. Every factory method on it — controllers, widgets, cookie manager, headless webview, print job, tracing, web storage — throws UnimplementedError by default, which is precisely what makes a partially implemented platform degrade to a clear runtime error instead of a null pointer. The full contract surface and its entity model are the subject of The Platform Interface: The Contract Seam.

Sources: inappwebview_platform.dart

Version Lockstep and the Single Source of Truth

Section titled “Version Lockstep and the Single Source of Truth”

All published packages ship the same version number, and that number has exactly one authoritative definition in the repository: a Dart constant. tool/versions.dart declares packageVersion and is documented as the single source of truth from which README snippets are regenerated by dart run tool/update_readmes.dart, with an explicit instruction never to hand-edit a version string in a README. The same file also pins the third-party family versions that appear in install snippets — Zorphy and the zuraffa family — so that a version bump is one edit in one file rather than a search-and-replace across the tree.

Propagation from that constant to the manifests is a script, not a discipline. scripts/prepare_for_publish.sh holds an explicit list of the eight packages under version management, rewrites each version: line, and then converts every inter-package path: dependency into a caret version constraint while stripping dependency_overrides entirely. That last step is the reason the script exists in this form: a published package must not carry path overrides, or its consumers would resolve against directories that do not exist on their machines.

flowchart LR
V["tool/versions.dart<br/>packageVersion"] --> R["README snippets<br/>update_readmes.dart"]
V --> P["scripts/prepare_for_publish.sh"]
P --> S1["rewrite version: in 8 pubspecs"]
S1 --> S2["path: -> ^version"]
S2 --> S3["strip dependency_overrides"]
S3 --> PUB["pub publish per package"]

The script also refuses to proceed when a git:-sourced override is present, on the grounds that stripping the override block would silently swap a fork for a hosted release that predates the fork’s API. This is the guard that protects the Windows fork relationship described earlier: the fork must be landed upstream and replaced by a hosted constraint before a publish can run.

Sources: versions.dart, prepare_for_publish.sh, prepare_for_publish.sh

Two Dependency Resolutions: Dev Checkout and Published Artifact

Section titled “Two Dependency Resolutions: Dev Checkout and Published Artifact”

Every package in the monorepo carries two descriptions of the same dependency graph. The dependencies block declares semantic constraints (zikzak_inappwebview_platform_interface: ^6.7.0) so the package remains publishable and resolvable in isolation. A dependency_overrides block, mirrored into a pubspec_overrides.yaml where one exists, redirects those same packages to sibling directories so that a local flutter pub get compiles the checkout rather than pub.dev. The overrides file is the local-development half of the pair; the publish script deletes the inline block, and the overrides file is not published at all.

Concern Dev resolution Published resolution
Inter-package deps path: ../<pkg> via overrides ^6.7.0 caret constraint
Umbrella → platforms overridden to siblings resolved from pub.dev
Module → core path: ../zikzak_inappwebview never published
Consumer example zikzak_inappwebview: path: ../ n/a (publish_to: none)

The module states this asymmetry as an intentional property rather than an oversight: because it is publish_to: none and is not covered by the publish script, anyone resolving its pubspec outside the monorepo layout will fail, and the manifest comment records that this is by design for a dev-only tier. The example app follows the same pattern from the consumer side, taking the umbrella by path and adding the web implementation explicitly.

Sources: pubspec_overrides.yaml, pubspec.yaml, pubspec.yaml, pubspec.yaml

The Second Federation: Core and Module Tiers

Section titled “The Second Federation: Core and Module Tiers”

Inside the umbrella’s lib/src/ there is a second, purely Dart-side split that the repository treats with the same rigour as the pub federation. SPLIT_MAP.md assigns every Dart value-add class under zikzak_inappwebview/lib/src/ to exactly one of two tiers: Core, the thin platform plugin that exposes raw APIs only, and Module, the policy, state, and agent-facing surface that lives in zikzak_inappwebview_module. The document is exhaustive by construction — its first validation rule is that every class appears exactly once — and it names the seam contract the module is allowed to consume: the InAppWebView widget, InAppWebViewController, HeadlessInAppWebView, CookieManager, the raw capture-event stream, and the two browser widgets.

graph BT
subgraph Core["Core tier — zikzak_inappwebview"]
W["InAppWebView / HeadlessInAppWebView"]
C["InAppWebViewController + domain facades"]
CM["CookieManager"]
NCP["raw capture-event plumbing"]
end
subgraph Module["Module tier — zikzak_inappwebview_module"]
P["Ports: WebViewSessionFactory, CaptureSource,<br/>CassetteEngine, RecipePort, DialogueDismissPort, NavigationTrackerPort"]
S["Services: WebViewPool, CaptureService"]
V["CassetteEngine impl + models"]
end
Module -->|"public API only"| Core
Core --> PI2["platform_interface (via barrel re-export)"]

The module’s own barrel confirms the intended dependency direction in code: it exports ports first, then services, models, and the VCR implementation, and its ports import the umbrella package — never the platform interface. A port such as WebViewSessionFactory is declared against HeadlessInAppWebView and InAppWebViewSettings drawn from the umbrella’s public barrel, with the doc comment stating that the module defines the interface and the core or an adapter supplies the implementation. That inversion is what lets WebViewPool be tested with an injected HeadlessWebViewInstanceFactory fake and no platform channels at all.

Sources: SPLIT_MAP.md, SPLIT_MAP.md, zikzak_inappwebview_module.dart, webview_session_factory.dart, webview_pool.dart

The Grep Gate as an Architectural Invariant

Section titled “The Grep Gate as an Architectural Invariant”

A two-tier split that is documented but not enforced decays, so this repository enforces it with a shell script that runs as a structural gate. scripts/grep_gate.sh scans zikzak_inappwebview/lib/src for a fixed list of intelligence-layer identifiers — WebViewPool, CaptureSource, CassetteEngine, DialogueDismissPort, RecipePort, NavigationTrackerPort, VCRWrapper, and their snake-case file stems — and fails if any appears in the core. It then performs the converse check, failing if anything under zikzak_inappwebview_module/lib imports zikzak_inappwebview_platform_interface. Exit 0 means the tiers are clean; exit 1 prints the offending files.

The gate also encodes the one deliberate exception. Raw capture-event source plumbing — the JavaScript injection and event channel wiring — is allowed to remain in the core, so network_capture_interceptor_js is listed as a carve-out pattern and matches in that file are skipped. Only the capture management policy (filtering, budget enforcement, routing) moves to the module as the CaptureSource adapter. This is the distinction the split map draws between raw plumbing and policy, expressed as an executable rule rather than a comment.

Sources: grep_gate.sh, grep_gate.sh, SPLIT_MAP.md

The physical layout below is the top of the tree with the roles annotated; per-package internals are covered on the platform pages.

zikzak_inappwebview/ # umbrella: lib/zikzak_inappwebview.dart barrel
lib/src/ # core tier (grep-gated)
in_app_webview/ # widget, controller, headless, controllers/, network_capture/
in_app_browser/ chrome_safari_browser/ # browser widgets
web_storage/ web_message/ print_job/ # raw facades
navigation_tracker/ session_recipe/ # (present in tree; module tier per split map)
dialogue_dismisser/ webview_sessions/
test/ example/ .gym/
zikzak_inappwebview_platform_interface/ # contract: inappwebview_platform.dart + domain/entities/
zikzak_inappwebview_{android,ios,macos,linux,web,windows}/
zikzak_webview_windows/ # WebView2 fork (native C++)
zikzak_inappwebview_ohos/ # ArkWeb; implements but unregistered in umbrella
zikzak_inappwebview_module/ # module tier: src/{ports,services,models,vcr}
tool/ # versions.dart (version SoT), update_readmes.dart
scripts/ # prepare_for_publish.sh, grep_gate.sh, publish.sh, local_ci.sh
specs/ .specify/ # spec-kit specs, TDD, constitution

One inconsistency is worth flagging as a factual observation rather than a conclusion: AGENTS.md describes the repository as ten packages and states that zikzak_webview_windows is not version-locked to the 6.x line, while the tree contains eleven package directories and that fork’s manifest declares version: 6.7.0. What the manifests do establish unambiguously is that the fork is absent from the publish script’s package list, so its version is not managed by the lockstep tooling.

Sources: AGENTS.md, pubspec.yaml, prepare_for_publish.sh

The layout on this page is the map; the next pages walk the seams it exposes. Continue with The Platform Interface: The Contract Seam for the abstract registry and entity model, then Two-Tier Core/Module Split and the Grep Gate for the enforcement mechanics in depth, and Domain Controller Facades: Navigation, JavaScript, Cookies, Settings for how the core’s public surface is actually organised. If you came here to understand a specific platform’s native code, jump to Android Native Layer (Java), Apple Native Layer (Swift and Swift Package Manager), or Windows WebView2 Facade and the DevTools Fork — the fork relationship summarised here is expanded there.