Navigation Drawer

BottomNavigationBar  is a widget in Flutter that lets users switch between different views or screens using a bar at the bottom of the app. It’s a key navigation pattern in many mobile apps, especially for organizing major features like Home, Search, and Profile.

Source Code​

				
					class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _currentIndex = 0;

  final List<Widget> _pages = [
    Center(child: Text('Home Page')),
    Center(child: Text('Search Page')),
    Center(child: Text('Profile Page')),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Bottom Tab Nav')),
      body: _pages[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        onTap: (int index) {
          setState(() {
            _currentIndex = index;
          });
        },
        selectedItemColor: Colors.teal,
        unselectedItemColor: Colors.grey,
        backgroundColor: Colors.white,
        type: BottomNavigationBarType.fixed,
        items: [
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            label: 'Home',
            tooltip: 'Go to Home',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.search),
            label: 'Search',
            tooltip: 'Find something',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.person),
            label: 'Profile',
            tooltip: 'View your profile',
          ),
        ],
      ),
    );
  }
}

				
			

Ai Code Analizer

🎨 3. Important Properties Used

PropertyDescription
currentIndexIndicates which tab is currently active.
onTapCallback that updates the active tab on tap.
itemsList of BottomNavigationBarItems representing each tab.
selectedItemColorColor of the selected tab.
unselectedItemColorColor of the tabs not currently selected.
backgroundColorBackground color of the navigation bar.
typeLayout behavior — use fixed for >3 tabs or shifting for animations.
tooltipOptional label shown on long press (improves accessibility).