Route
Defines a single route in the route tree.
Routes can be nested via children to create layout hierarchies.
A route with component and children acts as a layout route — its
component should call use_route_outlet to render the
matched child.
Parameters:
- path (str | None, default:
None) - Relative path segment. Supports dynamic segments (:name), optional segments (:name?), splats (:name*), and custom regex constraints (:name(\\d+)).Nonefor pathless layout routes. - index (bool, default:
False) - WhenTrue, this route matches when the parent path matches exactly (no further segments). Index routes must not havepathorchildren. - component (Callable | None, default:
None) - A@componentfunction to render when this route matches. - children (list[Route] | None, default:
None) - Nested child routes. - loader (Callable[..., Any] | None, default:
None) - Optional data loader function. Called with the matched params dict when the route matches. Result is available viause_route_loader_data. - outlet (bool, default:
False) - WhenTrueandmanage_views=True, this route acts as a layout that wraps its matched child viause_route_outletwithin a singleView, instead of each child becoming a separateView. - modal (bool, default:
False) - WhenTrueandmanage_views=True, the route's View is rendered as a modal overlay on top of the existing stack instead of replacing it. The route's component should setfullscreen_dialog=Trueon its returnedViewso Flutter renders the slide-up presentation and a close (X) icon. Placement controls the base stack: * Declared at the top level: a global modal. The base stack is rebuilt from the last non-modal location the Router saw (defaults to"/"on first render). * Declared as a child of a non-modal route: a local modal. The base stack is the chain above the modal in the route tree, so deep-link works from the URL alone. On pop, the Router navigates to the resolved URL of the non-modal parent — never toviews[-2].route— so a modal close is always a real navigation back to the base location. - recursive (bool, default:
False) - WhenTrue, the route can match itself as its own descendant — one matched_RouteMatchper consumed segment. Useful for tree-shaped URLs with unbounded depth (e.g./folder/a/b/c) where each segment should become its own stack entry. Non-recursive children are tried before self-recursion at every depth so a more specific sibling (e.g.example/:gp*) wins over the recursive:slug.
Properties
componentclass-attributeinstance-attribute
component: Callable | None = Noneindexclass-attributeinstance-attribute
index: bool = Falseloaderclass-attributeinstance-attribute
loader: Callable[..., Any] | None = Nonemodalclass-attributeinstance-attribute
modal: bool = Falseoutletclass-attributeinstance-attribute
outlet: bool = Falsepathclass-attributeinstance-attribute
path: str | None = Nonerecursiveclass-attributeinstance-attribute
recursive: bool = False