navigation_rail.dart 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import 'package:flutter/material.dart';
  2. class CustomNavigationRail extends StatefulWidget {
  3. const CustomNavigationRail({super.key, required selectedIndex});
  4. @override
  5. State<CustomNavigationRail> createState() => Custom_NavigationRailState();
  6. }
  7. class Custom_NavigationRailState extends State<CustomNavigationRail> {
  8. int selectedIndex = 0;
  9. @override
  10. Widget build(BuildContext context) {
  11. return NavigationRail(
  12. backgroundColor: Color.fromARGB(255, 25, 30, 41),
  13. selectedIndex: selectedIndex,
  14. onDestinationSelected: (int index) {
  15. setState(() {
  16. selectedIndex = index;
  17. });
  18. },
  19. labelType: NavigationRailLabelType.all,
  20. destinations: const [
  21. NavigationRailDestination(
  22. icon: Icon(Icons.home, color: Colors.white),
  23. selectedIcon: Icon(Icons.home_filled),
  24. label: Text('Inicio'),
  25. ),
  26. NavigationRailDestination(
  27. icon: Icon(Icons.search),
  28. selectedIcon: Icon(
  29. Icons.search_rounded,
  30. color: Colors.white,
  31. ),
  32. label: Text('Buscar'),
  33. ),
  34. NavigationRailDestination(
  35. icon: Icon(Icons.settings),
  36. selectedIcon: Icon(Icons.settings_rounded, color: Colors.white),
  37. label: Text('Ajustes'),
  38. ),
  39. ],
  40. );
  41. }
  42. }