Skip to content

Instantly share code, notes, and snippets.

@Gogetter
Created May 27, 2018 19:22
Show Gist options
  • Save Gogetter/f1cc34facb5e2f685ad5743275f359ae to your computer and use it in GitHub Desktop.
Save Gogetter/f1cc34facb5e2f685ad5743275f359ae to your computer and use it in GitHub Desktop.
Flutter - Adding drawer items to Drawer
drawer: new Drawer(
child: new ListView(
children: <Widget>[
//display current user info
new UserAccountsDrawerHeader(
decoration: new BoxDecoration(color: Colors.white),
currentAccountPicture: new CircleAvatar(
backgroundImage: currentUser.photoUrl.isNotEmpty ?
new NetworkImage(currentUser.photoUrl) : currentUser.displayName.substring(0)),
accountName: new Text('Welcome, ${currentUser.displayName}', style: _userInfoTxtStyle),
accountEmail: new Text(currentUser.email?? '', style: _userInfoTxtStyle)
),
//Drawer items
new ListTile(
leading: new Icon(Icons.home),
title: new Text(Strings.home, style: _drawerItemTxtStyle),
onTap: () {
//update state
setState(() {
_displayMessage = 'You are home ${currentUser.displayName}';
});
// close Drawer window
Navigator.pop(context);
},
),
new Divider(color: Colors.blueGrey[200]),
new ListTile(
leading: new Icon(Icons.info),
title: new Text(Strings.aboutUs, style: _drawerItemTxtStyle),
onTap: () {
//update state
setState(() {
_displayMessage = 'About Us --- Coming Soon...';
});
// close Drawer window
Navigator.pop(context);
},
),
new Divider(color: Colors.blueGrey[200]),
new ListTile(
leading: new Icon(Icons.close),
title: new Text(Strings.logOut, style: _drawerItemTxtStyle),
onTap: () {
Navigator.pop(context);
// sign out
FirebaseAuth.instance.signOut();
// navigate to Welcome page
Navigator.push(context, new MaterialPageRoute(
builder: (_) => new MyApp(),
));
},
)
],
),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment