Router class

Stores a set of UrlPattern to Handler associations and provides methods for calling a handler for a URL path, listening to Window history events, and creating HTML event handlers that navigate to a URL.

Constructors

Router({bool useFragment: true})
useFragment determines whether this Router uses pure paths with History.pushState or paths + fragments and Location.assign. The default value is null which then determines the behavior based on History.supportsState.

Properties

onEnter → Stream<RouteEnterEvent>
read-only
onError → Stream<RouteErrorEvent>
read-only
useFragment → bool
final
hashCode → int
The hash code for this object.
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

addRoute({String name, dynamic path, RouteEnterCallback enter: _defaultEnterCallback}) → void
Registers a function that will be invoked when the router handles a URL that matches pattern. [...]
downgrade() → void
Cancels all the registered streams [...]
go(String name, {List<String> params: const []}) → void
Searches a route by its name
gotoPath(String path, {bool testing: false}) → void
Goes to specific path [...]
gotoUrl(UrlPattern urlPattern, List<String> params) → void
Navigates the browser to the path produced by urlPattern with params by calling History.pushState, then invokes the handler associated with urlPattern. [...]
listen({bool ignoreClick: false}) → void
Listens for window history events and invokes the router. On older browsers the hashChange event is used instead.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator.
inherited