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:

  1. the widget callbacks forwarded via onLoadStart, onUpdateVisitedHistory and onServerRedirect;
  2. 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 onWebViewCreated to 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 controller and flushes events the page buffered before registration. Call from onWebViewCreated.
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 onLoadStart callback.
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 onUpdateVisitedHistory callback.
onUserOverride(WebUri? url) → void
Forward a shouldOverrideUrlLoading observation.
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 userScripts unchanged when tracker is null.

Constants

dedupWindow → const Duration
Deduplication window: same URL within this window collapses to one entry.