-
-
Save granoeste/a43744524c0c8dbfa2bd2885d51aa6e6 to your computer and use it in GitHub Desktop.
Navigation Drawer
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'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
final appTitle = 'Drawer Demo'; | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: appTitle, | |
home: MyHomePage(title: appTitle), | |
); | |
} | |
} | |
class MyHomePage extends StatelessWidget { | |
final String title; | |
MyHomePage({Key key, this.title}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(title: Text(title)), | |
body: Center(child: Text('Content')), | |
drawer: Drawer( | |
child: ListView( | |
padding: EdgeInsets.zero, | |
children: <Widget>[ | |
ListTile( | |
title: Text('Acount'), | |
onTap: () { | |
showDialog<bool>( | |
context: context, | |
builder: (BuildContext context) { | |
return AlertDialog( | |
content: const Text('Do you want logout?'), | |
actions: <Widget>[ | |
FlatButton( | |
child: const Text('No'), | |
onPressed: () { | |
Navigator.of(context).pop(false); | |
}, | |
), | |
FlatButton( | |
child: const Text('Yes'), | |
onPressed: () { | |
Navigator.of(context).pop(true); | |
}, | |
), | |
], | |
); | |
}, | |
); | |
}, | |
), | |
ListTile( | |
title: Text('Terms of service'), | |
onTap: () { | |
// Dummy Navigation | |
Navigator.pop(context); | |
}, | |
), | |
ListTile( | |
title: Text('About'), | |
onTap: () { | |
showAboutDialog( | |
context:context, | |
applicationName: 'Navigation Drawer', | |
applicationVersion: '1.0.0', | |
); | |
}, | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment