route method Null safety

Linkable route(
  1. String pattern

Adds a route that Controllers can be linked to.

Routers allow for multiple linked controllers. A request that matches pattern will be sent to the controller linked to this method's return value.

The pattern must follow the rules of route patterns (see also

A pattern consists of one or more path segments, e.g. "/path" or "/path/to".

A path segment can be:

  • A literal string (e.g. users)
  • A path variable: a literal string prefixed with : (e.g. :id)
  • A wildcard: the character *

A path variable may contain a regular expression by placing the expression in parentheses immediately after the variable name. (e.g. :id(/d+)).

A path segment is required by default. Path segments may be marked as optional by wrapping them in square brackets [].

Here are some example routes:



Linkable route(String pattern) {
  var routeController = _RouteController(
  return routeController;