MotorSignal-App/lib/core/router.dart

56 lines
1.5 KiB
Dart

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/settings/settings_screen.dart';
import 'widgets/main_layout.dart';
final _rootNavigatorKey = GlobalKey<NavigatorState>();
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: '/settings',
builder: (context, state) => const SettingsScreen(),
),
],
),
],
),
],
);