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
| Name | Description |
|---|---|
initialLocation | Required. 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. |
redirectLimit | Default 5. |
observers | Extra NavigatorObservers. VoRouteObserver (debug logging) is always added. |
errorBuilder | Page shown for unknown routes. |
debugLogDiagnostics | go_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(),
)Navigating
| Name | Description |
|---|---|
context.go / push / pop | Standard 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 / canPop | Inspect the navigation state. |
ref.read(voRouterProvider) | The GoRouter, for navigating outside the widget tree. |
voNavigatorKey | The root navigator key. |