Skip to content

Instantly share code, notes, and snippets.

@SteveOye

SteveOye/main.dart

Last active May 22, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.