NavigationTracker class
Unified, ordered URL-cycle stream for a WebView.
Merges every URL-change source the package exposes into one ordered, deduplicated list of UrlCycleEntrys:
- the widget callbacks forwarded via onLoadStart, onUpdateVisitedHistory and onServerRedirect;
- the injected tracker UserScript (see buildNavigationTrackerJs)
which monkey-patches the history API and listens to
popstate/hashchange/pageshow, reported through the__zikzakNavigationTracker__JavaScript handler.
Dedup rule: the same URL observed within a 500ms window collapses to one entry, keeping the earliest trigger.
The tracker works without a WebView: handleJsPayload and the forwarder methods operate on a plain instance; attach only wires the JS bridge.
Constructors
-
Creates a tracker. Usable without a WebView; call attach from
onWebViewCreatedto wire the JS bridge.
Properties
-
entries
→ List<
UrlCycleEntry> -
Ordered, deduplicated URL-cycle entries.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- mainFrameOnly → bool
-
Whether sub-frame URL changes are dropped (default
true).final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
attach(
InAppWebViewController controller) → void -
Registers the JavaScript handler on
controllerand flushes events the page buffered before registration. Call fromonWebViewCreated. -
buildUserScript(
) → UserScript - Builds the tracker script to add to the initial user scripts.
-
detach(
) → void - Removes the JavaScript handler.
-
handleJsPayload(
Map< String, dynamic> payload) → void - Processes a raw payload reported by the injected tracker script. Public so it can be unit-tested without a WebView.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onLoadStart(
WebUri? url) → void -
Forward from the widget's
onLoadStartcallback. -
onServerRedirect(
) → void - Forward from the widget's server-redirect callback (iOS/macOS). The callback carries no URL, so the last recorded URL is reused.
-
onUpdateVisitedHistory(
WebUri? url) → void -
Forward from the widget's
onUpdateVisitedHistorycallback. -
onUserOverride(
WebUri? url) → void -
Forward a
shouldOverrideUrlLoadingobservation. -
recordEntry(
{required String? url, required UrlCycleTrigger trigger, int? timestamp, bool isMainFrame = true}) → void - Records a URL change, applying the main-frame filter and the 500ms dedup window (earliest trigger wins).
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
maybeCreate(
{UrlCycleEntryCallback? onUrlCycleEntry}) → NavigationTracker? -
Creates a tracker (same convention as
NetworkCaptureManager.maybeCreate). -
mergeUserScripts(
List< UserScript> ? userScripts, NavigationTracker? tracker) → UnmodifiableListView<UserScript> ? -
Merges the tracker script into the user-provided scripts.
Returns
userScriptsunchanged whentrackerisnull.
Constants
- dedupWindow → const Duration
- Deduplication window: same URL within this window collapses to one entry.