SimpleRouteConfig<TRouteData extends Widget> class
abstract
Dark Router: Base Route Configs
This file defines 3 base abstractions that standardize how we configure GoRouter routes in a type-safe way:
-
- For normal pages that don't need async fetching.
- Example: static screens, detail pages where all data is passed via query params / extra.
-
- For pages that require async data loading (fetch by ID, etc.).
- Example:
/product/:idthat must fetch the product from API/DB.
-
- For building a
StatefulShellRoute.indexedStackshell with multiple tabs/branches. - Example: main bottom navigation container with 3–5 tabs.
- For building a
These abstractions:
- Keep route registration consistent across the app.
- Let you define routes as typed configs instead of ad-hoc functions.
- Make it easier to share routing patterns across projects.
See usage examples at the bottom of this file.
- SimpleRouteConfig
Use this for routes that:
- Do NOT need async data fetching.
- Only depend on
GoRouterState(path params, query params, extra, etc.).
Typical usage:
class HomeRouteConfig extends SimpleRouteConfig<HomeScreen> {
const HomeRouteConfig();
@override
String get name => 'home';
@override
HomeScreen routeConfig(GoRouterState state) {
// You can parse query params/extra here if needed.
return const HomeScreen();
}
}
// When registering routes with GoRouter:
final homeConfig = HomeRouteConfig();
GoRoute(
name: homeConfig.name,
path: homeConfig.path,
builder: (context, state) => homeConfig.routeConfig(state),
);
Constructors
- SimpleRouteConfig()
-
const
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
routeConfig(
GoRouterState state) → TRouteData -
Convert a
GoRouterStateinto the final widget for this route. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited