Skip to content

Instantly share code, notes, and snippets.

@SteveOye
Last active May 22, 2020 01:33
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 SteveOye/636c9a34f0812660c15a734960cc2dfb to your computer and use it in GitHub Desktop.
Save SteveOye/636c9a34f0812660c15a734960cc2dfb to your computer and use it in GitHub Desktop.
Bottom Navigation main.dart code
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