RouteDefinition class

A fluent route definition builder.

This class represents a single route and supports method chaining for a clean, expressive API similar to Laravel's routing.

Basic Usage

MagicRoute.get('/users', () => UsersPage());
MagicRoute.get('/users/:id', (id) => UserDetailPage(id: id));

Fluent Chaining

MagicRoute.get('/dashboard', () => controller.index())
    .name('dashboard')
    .middleware(['auth'])
    .transition(RouteTransition.fade);

Constructors

RouteDefinition({required String path, required Function handler, String method = 'GET'})
Create a new route definition.

Properties

fullPath String
Get the full path including any group prefix.
no setter
groupPrefix String?
Set the group prefix (internal use).
no getter
handler Function
The handler function that returns a Widget.
final
hashCode int
The hash code for this object.
no setterinherited
method String
HTTP method (GET, POST, etc.) - primarily for documentation.
final
middlewares List
Get the list of middleware (strings or factories).
no setter
path String
The URL path pattern (e.g., '/users/:id').
final
routeName String?
Get the route name, if defined.
no setter
routeTitle String?
Get the page title, if defined.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
transitionType RouteTransition
Get the transition type.
no setter

Methods

buildWidget(Map<String, String> pathParameters) Widget
Build the widget from the handler, passing parameters if needed.
middleware(List middlewares) RouteDefinition
Apply middleware to this route.
name(String routeName) RouteDefinition
Assign a name to this route for named navigation.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
title(String pageTitle) RouteDefinition
Set the page title for this route.
toString() String
A string representation of this object.
inherited
transition(RouteTransition type) RouteDefinition
Set the page transition animation.

Operators

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