Created
March 7, 2020 07:42
-
-
Save zafarivaev/62c71b2425e14fa8a0a71b2c7dccad3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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