Last active
May 22, 2020 01:33
-
-
Save SteveOye/636c9a34f0812660c15a734960cc2dfb to your computer and use it in GitHub Desktop.
Bottom Navigation main.dart code
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 MyApp extends StatefulWidget { | |
@override | |
_MyAppState createState() => _MyAppState(); | |
} | |
class _MyAppState extends State<MyApp> { | |
int _selectedPage = 0; | |
final _page = [ | |
HomePage(), | |
HistoryPage(), | |
SupportPage(), | |
ProfilePage(), | |
]; | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Bottom Navigation', | |
theme: ThemeData(primarySwatch: Colors.green), | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text('Bottom Navigation'), | |
), | |
body: _page[_selectedPage], | |
bottomNavigationBar: BottomNavigationBar( | |
currentIndex: _selectedPage, | |
unselectedItemColor: Color.fromRGBO(58, 58, 58, 100), | |
selectedItemColor: Colors.green, | |
onTap: (int index) { | |
setState(() { | |
_selectedPage = index; | |
}); | |
}, | |
items: [ | |
BottomNavigationBarItem( | |
icon: Icon(Icons.home), | |
title: Text('Home'), | |
), | |
BottomNavigationBarItem( | |
icon: Icon(Icons.timeline), | |
title: Text('History'), | |
), | |
BottomNavigationBarItem( | |
icon: Icon(Icons.chat), | |
title: Text('Support'), | |
), | |
BottomNavigationBarItem( | |
icon: Icon(Icons.account_circle), | |
title: Text('Profile'), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment