Router class

Route registration DSL.

Constructors

Router()
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
routes → List<RouteData>
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

acceptQuery(List<String> mediaTypes) → Router
The media types this QUERY route takes, such as application/json; type/* and */* match a family or anything. A request with another type is answered with a 415, and the list is advertised in the Accept-Query header.
domain([String? domain]) → Router
middleware([List<Middleware>? middleware]) → Router
name([String? name]) → Router
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
prefix([String? prefix]) → Router
toString() → String
A string representation of this object.
inherited
where(String paramName, String regex) → Router
whereBool(String paramName) → Router
whereDouble(String paramName) → Router
whereInt(String paramName) → Router
whereString(String paramName) → Router

Operators

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

Static Methods

any(String path, Function action) → Router
A route for every HTTP method. Anything chained after it applies to all of them.
apiResource(String path, dynamic controller, {String? prefix, List<Middleware>? middleware, String? domain, String regex = r'\d+(\.\d+)?'}) → void
The routes of a JSON API resource: index, store, show, update (under both PUT and PATCH) and destroy.
basePrefix([String? prefix]) → void
copy(String path, Function action) → Router
delete(String path, Function action) → Router
get(String path, Function action) → Router
group(Function callback, {String? prefix = '', List<Middleware> middleware = const [], String? domain}) → void
lock(String path, Function action) → Router
options(String path, Function action) → Router
patch(String path, Function action) → Router
post(String path, Function action) → Router
propfind(String path, Function action) → Router
purge(String path, Function action) → Router
put(String path, Function action) → Router
query(String path, Function action) → Router
A QUERY route (RFC 10008): a safe, idempotent read like GET, with the query in the request content instead of the URL — so it is not limited in length, and is less often written to logs on the way.
resource(String path, dynamic controller, {String? prefix, List<Middleware>? middleware, String? domain, String regex = r'\d+(\.\d+)?'}) → void
unlock(String path, Function action) → Router
url(String name, [Map<String, dynamic>? params]) → String