Skip to content

Instantly share code, notes, and snippets.

@zafarivaev
Created March 7, 2020 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zafarivaev/62c71b2425e14fa8a0a71b2c7dccad3c to your computer and use it in GitHub Desktop.
Save zafarivaev/62c71b2425e14fa8a0a71b2c7dccad3c to your computer and use it in GitHub Desktop.
class _HomePageState extends State<HomePage> {
int _selectedIndex = 0;
static const List<BottomNavigationBarItem> _navigationBarItems = [
BottomNavigationBarItem(
title: Text('Home'),
icon: Icon(Icons.home),
),
BottomNavigationBarItem(
title: Text('Search'),
icon: Icon(Icons.search),
),
BottomNavigationBarItem(
title: Text('Profile'),
icon: Icon(Icons.account_circle),
),
];
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: BottomNavigationBar(
items: _navigationBarItems,
currentIndex: _selectedIndex,
selectedItemColor: Colors.green,
onTap: _onItemTapped,
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment