BrowserRouter<T> class abstract

A variation of the Router support both hash routing and push state.

Inheritance

Constructors

BrowserRouter({bool hash = false, bool listen = false})
Set hash to true to use hash routing instead of push state. listen as true will call listen after initialization.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
middleware List<T>
no setterinherited
mounted Map<Pattern, Router<T>>
no setterinherited
onResolve Stream<RoutingResult<T?>>
Fires whenever the active route changes. Fires null if none is selected (404).
no setter
onRoute Stream<Route<T?>>
Fires whenever the active route changes. Fires null if none is selected (404).
no setter
routes List<Route<T>>
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addRoute(String method, String path, T handler, {Iterable<T> middleware = const []}) Route<T>
Adds a route that responds to the given path for requests with the given method (case-insensitive). Provide '*' as the method to respond to all methods.
inherited
all(String path, T handler, {Iterable<T> middleware = const []}) Route<T>
Adds a route that responds to any request matching the given path.
inherited
chain(Iterable<T> middleware) ChainedRouter<T>
Prepends the given middleware to any routes created by the resulting router.
inherited
clone() Router<T>
Returns a Router with a duplicated version of this tree.
inherited
delete(String path, T handler, {Iterable<T> middleware = const []}) Route<T>
Adds a route that responds to a DELETE request.
inherited
dumpTree({dynamic callback(String tree)?, String header = 'Dumping route tree:', String tab = ' '}) → void
Creates a visual representation of the route hierarchy and passes it to a callback. If none is provided, print is called.
inherited
enableCache() → void
Enables the use of a cache to eliminate the overhead of consecutive resolutions of the same path.
inherited
get(String path, T handler, {Iterable<T> middleware = const []}) Route<T>
Adds a route that responds to a GET request.
inherited
go(List linkParams) → void
Navigates to the path generated by calling navigate with the given linkParams.
group(String path, void callback(Router<T> router), {Iterable<T> middleware = const [], String name = ''}) SymlinkRoute<T>
Creates a route, and allows you to add child routes to it via a Router instance.
inherited
groupAsync(String path, FutureOr<void> callback(Router<T> router), {Iterable<T> middleware = const [], String name = ''}) Future<SymlinkRoute<T>>
Asynchronous equivalent of group.
inherited
Adds a route that responds to a HEAD request.
inherited
listen() → void
Begins listen for location changes.
mount(String path, Router<T> router) SymlinkRoute<T>
Incorporates another Router's routes into this one's.
inherited
Generates a URI string based on the given input. Handy when you have named routes.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
on(String path, T handler, {Iterable<T> middleware}) Route
Identical to all.
options(String path, T handler, {Iterable<T> middleware = const {}}) Route<T>
Adds a route that responds to a OPTIONS request.
inherited
patch(String path, T handler, {Iterable<T> middleware = const []}) Route<T>
Adds a route that responds to a PATCH request.
inherited
post(String path, T handler, {Iterable<T> middleware = const []}) Route<T>
Adds a route that responds to a POST request.
inherited
put(String path, T handler, {Iterable<T> middleware = const []}) Route
Adds a route that responds to a PUT request.
inherited
resolve(String absolute, String relative, List<RoutingResult<T?>> out, {String method = 'GET', bool strip = true}) bool
Finds the first Route that matches the given path, with the given method.
inherited
resolveAbsolute(String path, {String method = 'GET', bool strip = true}) Iterable<RoutingResult<T>>
Returns the result of resolve with path passed as both absolute and relative.
inherited
resolveAll(String absolute, String relative, {String method = 'GET', bool strip = true}) Iterable<RoutingResult<T>>
Finds every possible Route that matches the given path, with the given method.
inherited
toString() String
A string representation of this object.
inherited

Operators

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