Router class
A hierarchical Router supporting:
- Sub-groups (each can have path + middlewares)
- Multiple HTTP verbs
- Group-level middlewares
- Route-level middlewares
- Hierarchical naming
- Available extensions
Constructors
-
Router({String path = '', String? groupName, List<
Middleware> middlewares = const []}) - Constructor
Properties
-
groupMiddlewares
→ List<
Middleware> -
Middlewares declared for this router group only.
(We do not manually copy the parent's middlewares here.)
final
- groupName ↔ String?
-
Optional group name (e.g.
api)getter/setter pair - hashCode → int
-
The hash code for this object.
no setterinherited
-
routes
→ List<
RegisteredRoute> -
Public getter so tests or merges can inspect routes.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
any(
String path, Handler handler, {List< Middleware> middlewares = const [], Map<String, dynamic> constraints = const {}, Object? schema}) → RouteBuilder - Registers a route that accepts any HTTP method.
-
build(
{String? parentGroupName, List< Middleware> inheritedMiddlewares = const [], String parentPrefix = ''}) → void - Build merges naming & middlewares.
-
connect(
String path, RouteHandler handler, {List< Middleware> middlewares = const [], Map<String, dynamic> constraints = const {}, Object? schema}) → RouteBuilder - Registers a CONNECT route with the router.
-
delete(
String path, RouteHandler handler, {List< Middleware> middlewares = const [], Map<String, dynamic> constraints = const {}, Object? schema}) → RouteBuilder - Registers a DELETE route with the router.
-
fallback(
Handler handler, {List< Middleware> middlewares = const []}) → RouteBuilder - Registers a fallback route with the router.
-
get(
String path, RouteHandler handler, {List< Middleware> middlewares = const [], Map<String, dynamic> constraints = const {}, Object? schema}) → RouteBuilder - Registers a GET route with the router.
-
getAllRoutes(
) → List< RegisteredRoute> - Flatten all routes (this router + children + deeper descendants)
-
getAllWebSocketRoutes(
) → List< RouterWebSocketRoute> - Creates a Router.
-
group(
{String path = '', List< Middleware> middlewares = const [], void builder(Router)?}) → RouterGroupBuilder - Create a sub-group (child router).
-
handle(
String method, String path, RouteHandler handler, {List< Middleware> middlewares = const [], Map<String, dynamic> constraints = const {}, Object? schema}) → RouteBuilder -
Internal helper to create and store a
RegisteredRoute. -
head(
String path, RouteHandler handler, {List< Middleware> middlewares = const [], Map<String, dynamic> constraints = const {}, Object? schema}) → RouteBuilder - Registers a HEAD route with the router.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
options(
String path, RouteHandler handler, {List< Middleware> middlewares = const [], Map<String, dynamic> constraints = const {}, Object? schema}) → RouteBuilder - Registers an OPTIONS route with the router.
-
patch(
String path, RouteHandler handler, {List< Middleware> middlewares = const [], Map<String, dynamic> constraints = const {}, Object? schema}) → RouteBuilder - Registers a PATCH route with the router.
-
post(
String path, RouteHandler handler, {List< Middleware> middlewares = const [], Map<String, dynamic> constraints = const {}, Object? schema}) → RouteBuilder - Registers a POST route with the router.
-
printRoutes(
) → void - Print all routes in this router + sub-routers to console.
-
put(
String path, RouteHandler handler, {List< Middleware> middlewares = const [], Map<String, dynamic> constraints = const {}, Object? schema}) → RouteBuilder - Registers a PUT route with the router.
-
resolveMiddlewareReferences(
MiddlewareRegistry registry, Container container) → void - Resolves MiddlewareReference placeholders into executable middleware.
-
signedStorage(
String relativePath, Filesystem storage, {required StorageSignedUrlSigner signer, String rootPath = '', String indexFile = 'index.html'}) → void -
Available on Router, provided by the RouterStaticFiles extension
Mounts private storage objects behind time-limited signed URLs. -
static(
String relativePath, String rootPath, {FileSystem? fileSystem, bool listDirectory = false}) → void -
Available on Router, provided by the RouterStaticFiles extension
Mounts a directory atrelativePathon this router. -
staticFile(
String relativePath, String filePath, [FileSystem? fs]) → void -
Available on Router, provided by the RouterStaticFiles extension
Mounts one file atrelativePathon this router. -
staticFileFS(
String relativePath, String filePath, Dir dir) → void -
Available on Router, provided by the RouterStaticFiles extension
Mounts one file using an explicit parent directorydir. -
staticFS(
String relativePath, Dir dir) → void -
Available on Router, provided by the RouterStaticFiles extension
Mounts a directory using an explicitdirdefinition. -
staticStorage(
String relativePath, Filesystem storage, {String rootPath = '', bool listDirectory = false, String indexFile = 'index.html'}) → void -
Available on Router, provided by the RouterStaticFiles extension
Mounts a directory from an asynchronousstorage_fsbackend. -
toString(
) → String -
A string representation of this object.
inherited
-
ws(
String path, WebSocketHandler handler, {List< Middleware> middlewares = const []}) → void - Registers a WebSocket route with the router.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited