Posted By

markt22 on 07/18/18


Tagged

flutter dart


Versions (?)

Flutter: App Drawer


 / Published in: JavaScript
 

Creates an app with a simple drawer

  1. class _MyHomePageState extends State<MyHomePage> {
  2. @override
  3. Widget build(BuildContext context) {
  4. return new Scaffold(
  5. appBar: new AppBar(
  6. title: Text(widget.title),
  7. ),
  8. body: Center(child: Text(widget.title)),
  9. drawer: Drawer(
  10. child: ListView(
  11. // Important: Remove any padding from the ListView.
  12. padding: EdgeInsets.zero,
  13. children: <Widget>[
  14. DrawerHeader(
  15. child: Text('Drawer Header'),
  16. decoration: BoxDecoration(
  17. color: Colors.blue,
  18. ),
  19. ),
  20. ListTile(
  21. title: Text('Item 1'),
  22. onTap: () {
  23. // Update the state of the app
  24. // ...
  25. Navigator.pop(context);
  26. },
  27. ),
  28. ListTile(
  29. title: Text('Item 2'),
  30. onTap: () {
  31. // Update the state of the app
  32. // ...
  33. Navigator.pop(context);
  34. },
  35. ),
  36. ])));
  37. }
  38. }

Report this snippet  

You need to login to post a comment.