Flutter · colveor_ui

Routing

Routes are plain go_router routes. The router itself is built and owned by colveor_ui.

Routes

routes.dart
Dart
import 'package:colveor_ui/routing.dart';

List<RouteBase> appRoutes(VoConfig config) => [
  GoRoute(path: '/splash', builder: (context, state) => const SplashScreen()),
  GoRoute(
    path: '/home',
    builder: (context, state) => const HomeScreen(),
    routes: [
      GoRoute(
        path: ':pane',
        builder: (context, state) =>
            HomeScreen(initialPaneKey: state.pathParameters['pane'] ?? 'home'),
      ),
    ],
  ),
];

VoRoutingConfig

NameDescription
initialLocationRequired. The first route.
redirect(ref, context, state) → String? — return a path to redirect, or null.
onInit(ref, notifier) — set up listeners that re-run redirects.
redirectLimitDefault 5.
observersExtra NavigatorObservers. VoRouteObserver (debug logging) is always added.
errorBuilderPage shown for unknown routes.
debugLogDiagnosticsgo_router diagnostics. Default false.

Guards

Call notifier.notify() whenever something your redirect depends on changes:

Dart
VoRoutingConfig(
  initialLocation: '/splash',
  onInit: (ref, notifier) =>
      ref.listen(authProvider, (_, _) => notifier.notify()),
  redirect: (ref, context, state) =>
      ref.read(authProvider).isSignedIn ? null : '/login',
  errorBuilder: (context, state) => const NotFoundScreen(),
)
NameDescription
context.go / push / popStandard go_router helpers, re-exported.
context.vo.push(route)Push a route.
context.vo.pushReplace(route)Replace the current route.
context.vo.pushAndClearStack(route)Go to a route, clearing the stack.
context.vo.pop([result])Pop, optionally with a result.
context.vo.currentPath / canPopInspect the navigation state.
ref.read(voRouterProvider)The GoRouter, for navigating outside the widget tree.
voNavigatorKeyThe root navigator key.