import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import '../features/dashboard/dashboard_screen.dart'; import '../features/map/map_screen.dart'; import '../features/history/history_screen.dart'; import '../features/records/records_screen.dart'; import '../features/settings/settings_screen.dart'; import '../features/settings/diagnostics_screen.dart'; import '../features/garage/garage_screen.dart'; import '../features/garage/add_motorcycle_screen.dart'; import '../features/garage/motorcycle_detail_screen.dart'; import 'widgets/main_layout.dart'; final _rootNavigatorKey = GlobalKey(); final appRouter = GoRouter( navigatorKey: _rootNavigatorKey, initialLocation: '/', routes: [ StatefulShellRoute.indexedStack( builder: (context, state, navigationShell) { return MainLayout(navigationShell: navigationShell); }, branches: [ StatefulShellBranch( routes: [ GoRoute( path: '/', builder: (context, state) => const DashboardScreen(), ), ], ), StatefulShellBranch( routes: [ GoRoute( path: '/map', builder: (context, state) => const MapScreen(), ), ], ), StatefulShellBranch( routes: [ GoRoute( path: '/history', builder: (context, state) => const HistoryScreen(), ), ], ), StatefulShellBranch( routes: [ GoRoute( path: '/records', builder: (context, state) => const RecordsScreen(), ), ], ), StatefulShellBranch( routes: [ GoRoute( path: '/garage', builder: (context, state) => const GarageScreen(), routes: [ GoRoute( path: 'add', builder: (context, state) => const AddMotorcycleScreen(), ), GoRoute( path: ':id', builder: (context, state) { final id = int.parse(state.pathParameters['id']!); return MotorcycleDetailScreen(motorcycleId: id); }, ), ], ), ], ), StatefulShellBranch( routes: [ GoRoute( path: '/settings', builder: (context, state) => const SettingsScreen(), routes: [ GoRoute( path: 'diagnostics', builder: (context, state) => const DiagnosticsScreen(), ), ], ), ], ), ], ), ], );