UrlBasedHistory class abstract

Base class for web History implementations backed by window.history.

This class wires up the browser popstate event and implements:

Subclasses are responsible for:

  • Exposing the current location by reading from window.location
  • Converting a target Uri into an href string via createHref

unrouter stores additional metadata in window.history.state so it can compute a HistoryEvent.delta when navigating back/forward.

Inheritance
Implementers

Constructors

UrlBasedHistory({Window? window})

Properties

action HistoryAction
The last navigation action performed by this history.
getter/setter pairoverride-getter
didPopJsFunction JSFunction
latefinal
hashCode int
The hash code for this object.
no setterinherited
index int
The current index in the history stack.
getter/setter pairoverride-getter
listeners List<void Function(HistoryEvent event)>
final
location RouteInformation
The current location, including the optional per-entry RouteInformation.state.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
window ↔ Window
latefinal

Methods

back() → void
Equivalent to calling go with -1.
inherited
createHref(Uri uri) String
Formats a Uri as an href for this history implementation.
inherited
dispose() → void
Releases resources held by the history (e.g. DOM event listeners).
override
forward() → void
Equivalent to calling go with +1.
inherited
go(int delta) → void
Moves within the history stack by delta entries.
override
listen(void listener(HistoryEvent event)) → void Function()
Registers a listener that is called when a pop navigation completes.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
push(Uri uri, [Object? state]) → void
Pushes a new history entry.
override
replace(Uri uri, [Object? state]) → void
Replaces the current history entry.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited