Skip to content

Instantly share code, notes, and snippets.

@granoeste
Forked from jcollins-g/index.html
Last active Oct 5, 2020
Embed
What would you like to do?
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