Components / Navigation
Navigation
Components for navigating between different sections of your app.
Structure
Code
// FlockUI Component: Navigation (Bottom Navigation)
// Description: A Material 3 bottom navigation bar with destinations for switching between primary views.
// Category: Structure
// External Dependencies: none
import 'package:flutter/material.dart';
class BottomNavBar extends StatefulWidget {
const BottomNavBar({super.key});
@override
State<BottomNavBar> createState() => _BottomNavBarState();
}
class _BottomNavBarState extends State<BottomNavBar> {
int _selectedIndex = 0;
static const _labels = ['Home', 'Search', 'Profile'];
static const _icons = [Icons.home, Icons.search, Icons.person];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text(
_labels[_selectedIndex],
style: Theme.of(context).textTheme.headlineMedium,
),
),
bottomNavigationBar: NavigationBar(
selectedIndex: _selectedIndex,
onDestinationSelected: (index) {
setState(() => _selectedIndex = index);
},
destinations: const [
NavigationDestination(
icon: Icon(Icons.home_outlined),
selectedIcon: Icon(Icons.home),
label: 'Home',
),
NavigationDestination(
icon: Icon(Icons.search_outlined),
selectedIcon: Icon(Icons.search),
label: 'Search',
),
NavigationDestination(
icon: Icon(Icons.person_outline),
selectedIcon: Icon(Icons.person),
label: 'Profile',
),
],
),
);
}
}
Preview