import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; /// Shell widget that provides bottom navigation for the app class AppBottomNavShell extends StatelessWidget { const AppBottomNavShell({ super.key, required this.child, }); final Widget child; @override Widget build(BuildContext context) { return Scaffold( body: child, bottomNavigationBar: _AppBottomNavigationBar(), ); } } class _AppBottomNavigationBar extends StatelessWidget { @override Widget build(BuildContext context) { final location = GoRouterState.of(context).matchedLocation; // Determine current index based on location int currentIndex = 0; if (location == '/') { currentIndex = 0; } else if (location.startsWith('/products')) { currentIndex = 1; } else if (location.startsWith('/categories')) { currentIndex = 2; } else if (location.startsWith('/settings')) { currentIndex = 3; } return NavigationBar( selectedIndex: currentIndex, onDestinationSelected: (index) { switch (index) { case 0: context.go('/'); break; case 1: context.go('/products'); break; case 2: context.go('/categories'); break; case 3: context.go('/settings'); break; } }, destinations: const [ NavigationDestination( icon: Icon(Icons.point_of_sale_outlined), selectedIcon: Icon(Icons.point_of_sale), label: 'Home', ), NavigationDestination( icon: Icon(Icons.inventory_2_outlined), selectedIcon: Icon(Icons.inventory_2), label: 'Products', ), NavigationDestination( icon: Icon(Icons.category_outlined), selectedIcon: Icon(Icons.category), label: 'Categories', ), NavigationDestination( icon: Icon(Icons.settings_outlined), selectedIcon: Icon(Icons.settings), label: 'Settings', ), ], ); } }