This repository has been archived on 2024-06-08. You can view files and clone it, but cannot push or open issues or pull requests.
SolarAgent/lib/layouts/navigation.dart

44 lines
1.0 KiB
Dart
Raw Normal View History

2024-02-07 17:25:58 +00:00
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
class AgentNavigation extends StatefulWidget {
const AgentNavigation({super.key, required this.router});
final GoRouter router;
static const items = [
NavigationDestination(
icon: Icon(Icons.home),
label: 'Dashboard',
),
NavigationDestination(
icon: Icon(Icons.account_circle),
label: 'Account',
)
];
static const destinations = ["/", "/account"];
@override
State<AgentNavigation> createState() => _AgentNavigationState();
}
class _AgentNavigationState extends State<AgentNavigation> {
int _selected = 0;
@override
Widget build(BuildContext context) {
return NavigationBar(
selectedIndex: _selected,
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
destinations: AgentNavigation.items,
onDestinationSelected: (index) {
widget.router.push(AgentNavigation.destinations[index]);
setState(() {
_selected = index;
});
},
);
}
}