xxxxxxxxxx
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text(
'Navigation Drawer',
),
backgroundColor: const Color(0xff764abc),
),
drawer: Drawer(
child: ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: [
const UserAccountsDrawerHeader( // <-- SEE HERE
decoration: BoxDecoration(color: const Color(0xff764abc)),
accountName: Text(
"Pinkesh Darji",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
accountEmail: Text(
"pinkesh.earth@gmail.com",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
currentAccountPicture: FlutterLogo(),
),
ListTile(
leading: Icon(
Icons.home,
),
title: const Text('Page 1'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
leading: Icon(
Icons.train,
),
title: const Text('Page 2'),
onTap: () {
Navigator.pop(context);
},
),
],
),
),
body: Center(
child: Column(
children: [
SizedBox(
height: 50,
),
],
),
),
);
xxxxxxxxxx
Scaffold(
drawer: Drawer(
child: ListView(
children: [
ListTile(
leading: Icon(Icons.message),
title: Text('Messages'),
),
ListTile(
leading: Icon(Icons.account_circle),
title: Text('Profile'),
),
ListTile(
leading: Icon(Icons.settings),
title: Text('Settings'),
),
],
)),
);
xxxxxxxxxx
Scaffold(
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
DrawerHeader(
child: Text("Header")),
ListTile(
title: Text("Home"))
]),
),
);
xxxxxxxxxx
Scaffold(
drawer: Drawer(
child: ListView(
children: [
ListTile(
leading: Icon(Icons.message),
title: Text('Messages'),
),
ListTile(
leading: Icon(Icons.account_circle),
title: Text('Profile'),
)
],
)),
body: Container(child: Center(child: InkWell(child: Text("Click to show drawer"), onTap: (){ Scaffold.of(context).openDrawer();})))
);
xxxxxxxxxx
class DrawerTutorial extends StatelessWidget {
const DrawerTutorial({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Drawer Tutorial"),
),
drawer: Drawer(
child: ListView(
children: const [
DrawerHeader(
child: Center(
child: Text(
"Welcome to AllAboutFlutter.com",
),
),
decoration: BoxDecoration(color: Colors.blue),
),
ListTile(
title: Text("Website for Flutter"),
),
ListTile(
title: Text(
"Subscribe to get notified for new tutorials.",
),
),
],
),
),
body: Center(
child: Wrap(
alignment: WrapAlignment.spaceAround,
children: [
RichText(
text: const TextSpan(
text: "Press the ",
style: TextStyle(color: Colors.black, fontSize: 32),
children: [
WidgetSpan(
child: Icon(
Icons.menu,
size: 32,
)),
TextSpan(text: " button to open the drawer"),
],
),
),
],
),
),
);
}
}