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:

  1. SimpleRouteConfig

    • For normal pages that don't need async fetching.
    • Example: static screens, detail pages where all data is passed via query params / extra.
  2. AsyncRouteConfig

    • For pages that require async data loading (fetch by ID, etc.).
    • Example: /product/:id that must fetch the product from API/DB.
  3. ShellIndexedStackConfig

    • For building a StatefulShellRoute.indexedStack shell with multiple tabs/branches.
    • Example: main bottom navigation container with 3–5 tabs.

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.


  1. 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

hashCode int
The hash code for this object.
no setterinherited
name String
A unique name for this route within GoRouter.
no setter
path String
Path of the route.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
routeConfig(GoRouterState state) → TRouteData
Convert a GoRouterState into the final widget for this route.
toString() String
A string representation of this object.
inherited

Operators

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