Routers Service
By default Aurora comes with a router service. This service is using the go_router package for navigation. This service is using the riverpod package for state management. This service is using the go_router_builder dev package for type-safe navigation.
├── routers
│ ├── app_router.dart
│ ├── app_router.g.dart
│ ├── router_provider.dart
│ └── router_provider.g.dartapp_router.dart
This file contains the AppRouter class. This class is responsible for providing the navigation service to the app. This class is using the go_router package for navigation.
Instead of using URL strings to navigate, I am using type-safe navigation in this app. For this I am using the go_router_builder dev package. This package is used to generate extended the AppRouter class.
Here is the AppRouter class with the go_router_builder annotations.
part 'app_router.g.dart';
@TypedGoRoute<HomeRoute>(
path: AppRouterPath.home,
routes: <TypedGoRoute<GoRouteData>>[],
)
class HomeRoute extends GoRouteData {
const HomeRoute();
@override
Widget build(BuildContext context, GoRouterState state) => const HomePage();
}
// Other routes
This file has a part file. This file is generated by the flutter pub run build_runner build command. This file is used to provide the localization service to the app.
// GENERATED CODE - DO NOT MODIFY BY HANDrouter_provider.dart
This file contains the GoRouter class. This class is responsible for providing the navigation service to the app. This class is using the riverpod package for state management.
part 'router_provider.g.dart';
@Riverpod(keepAlive: true)
// ignore: unsupported_provider_value
GoRouter router(RouterRef ref) {
final key = GlobalKey<NavigatorState>(debugLabel: 'routerKey');
return GoRouter(
navigatorKey: key,
debugLogDiagnostics: true,
initialLocation: ref.watch(initialRouteProvider),
routes: $appRoutes,
errorBuilder: (c, s) => ErrorRoute(error: s.error!).build(c, s));
}
This file has a part file. This file is generated by the flutter pub run build_runner build command. This file is used to provide the localization service to the app.
// GENERATED CODE - DO NOT MODIFY BY HAND