Created
June 20, 2018 10:25
-
-
Save paulallies/7fe067d948b5850a4ba10e341ae901f6 to your computer and use it in GitHub Desktop.
My Drawer Flutter Nav
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'; | |
class MyDrawer extends StatelessWidget { | |
_gotoPage(String route, BuildContext context) { | |
Navigator.of(context).pushReplacementNamed(route); | |
} | |
@override | |
Widget build(BuildContext context) { | |
// TODO: implement build | |
return new Drawer( | |
child: new ListView( | |
padding: EdgeInsets.all(16.0), | |
children: <Widget>[ | |
new ListTile( | |
leading: new Icon(Icons.home), | |
title: new Text('Home'), | |
onTap: () { | |
// change app state... | |
_gotoPage("/home", context); | |
}, | |
), | |
new ListTile( | |
leading: new Icon(Icons.info), | |
title: new Text('Page 2'), | |
onTap: () { | |
// change app state... | |
_gotoPage("/page2", context); | |
}, | |
), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment