Last active
February 11, 2019 08:15
-
-
Save redbluenat/ca68d10e0516a2cbadc6060b90aba1cc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import 'package:flutter/material.dart'; | |
import 'package:flutter/widgets.dart'; | |
class HomePage extends StatefulWidget { | |
HomePage({Key key}) : super(key: key); | |
@override | |
HomePageState createState() => HomePageState(); | |
} | |
class HomePageState extends State<HomePage> { | |
int selectedIndex = 0; | |
final widgetOptions = [ | |
Text('Beer List'), | |
Text('Add new beer'), | |
Text('Favourites'), | |
]; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Beer App'), | |
), | |
body: Center( | |
child: widgetOptions.elementAt(selectedIndex), | |
), | |
bottomNavigationBar: BottomNavigationBar( | |
items: <BottomNavigationBarItem>[ | |
BottomNavigationBarItem(icon: Icon(Icons.local_drink), title: Text('Beers')), | |
BottomNavigationBarItem( | |
icon: Icon(Icons.add_a_photo), title: Text('New Beer')), | |
BottomNavigationBarItem( | |
icon: Icon(Icons.favorite), title: Text('Favourites')), | |
], | |
currentIndex: selectedIndex, | |
fixedColor: Colors.deepPurple, | |
onTap: onItemTapped, | |
), | |
); | |
} | |
void onItemTapped(int index) { | |
setState(() { | |
selectedIndex = index; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment