DarkRoute extension


DarkRoute

Provides factory helpers to convert your custom route configuration classes (SimpleRouteConfig, AsyncRouteConfig) into ready-to-use GoRouter GoRoute instances.

WHY THIS EXISTS

Normally, GoRouter route definitions look like:

GoRoute(
  name: 'home',
  path: '/home',
  builder: (_, state) => HomeScreen(),
);

But once your app grows, you want:

  • strict consistency
  • typed data passing
  • centralized parsing of params
  • reusable definitions

So instead of manually writing constructors for every route, you write:

final home = DarkRoute.buildConfig(config: HomeRouteConfig());
final course = DarkRoute.futureBuildConfig(config: CourseRouteConfig());

This makes your routing layer:

  • predictable
  • type-safe
  • easy to maintain
  • easily shared across projects
on
  • GoRoute

Static Methods

buildConfig<TRouteData extends Widget>({required SimpleRouteConfig<TRouteData> config}) → GoRoute

Available on GoRoute, provided by the DarkRoute extension

Converts a SimpleRouteConfig into a standard GoRoute.
futureBuildConfig<TRouteData extends Widget, TFetchData>({required AsyncRouteConfig<TRouteData, TFetchData> config}) → GoRoute

Available on GoRoute, provided by the DarkRoute extension

Converts an AsyncRouteConfig into a GoRoute that: