Skip to content

Instantly share code, notes, and snippets.

@granoeste
Forked from jcollins-g/index.html
Last active October 5, 2020 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save granoeste/a43744524c0c8dbfa2bd2885d51aa6e6 to your computer and use it in GitHub Desktop.
Save granoeste/a43744524c0c8dbfa2bd2885d51aa6e6 to your computer and use it in GitHub Desktop.
Navigation Drawer
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