
In this tutorial you will learn how to add Navigation Drawer Layout in your Flutter App.
You will learn how to add Left Navigation Drawer ( Drawer which opens from start side or right side ) and right Navigation Drawer (Drawer layout which slides from end or left side of the screen).
We will be using following Widgets to add Drawer layout in our Flutter App:
- Scaffold Widget.
- ListView Widget.
- Divider Widget.
- ListTile Widget.
- Text Widget.
- Icon Widget.
- UserAccountsDrawerHeader Widget.
- Creating Scaffold
1. Creating Scaffold Widget
Scaffold is used to implement Drawer, Snackbar, App Bar, Bottom Sheet, Bottom Navigation Bar and Floating Action Button.
So to add Navigation Drawer in our Flutter App we are required to add Scaffold Widget first.
Than our Drawer Widget will become children of Scaffold Widget (We will add drawer inside Scaffold).
Scaffold Widget has 2 properties for Drawer layouts in Flutter.
- drawer (for Left to Right Navigation Drawer). Drawer layout which expand from Left side.
- endDrawer (for Right to Left Navigation Drawer). Drawer layout which opens/expand from Right side.
Scaffold(
drawer: // Here we will add Drawer Layout.
);
Adding Drawer widget in Scaffold
Scaffold(
drawer: Drawer (
child: // here we will add Drawer layout items in next step.
), );
Adding List Items in Drawer
Here we will add ListView Widget as children of Drawer Widget.
We are adding ListView here so user can scroll drawer items vertically.
ListView Widget requires array of Wdgets as ListView items.
Scaffold(
drawer: Drawer(
elevation: 20.0,
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
],
)),
)
Adding Header Layout in Drawer
At this step we are going to add first item in ListView which will be Drawer Header Layout.
For this purpose we have added UserAccountsDrawerHeader Widget.
We can add user name, user email and user profile picture in our Drawer header.
Scaffold(
drawer: Drawer(
elevation: 20.0,
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
UserAccountsDrawerHeader(
accountName: Text('Hammad Tariq'),
accountEmail: Text('developine.com@gmail.com'),
currentAccountPicture:
Image.network('https://hammad-tariq.com/img/profile.png'),
decoration: BoxDecoration(color: Colors.blueAccent),
),
],
)),
)
This will be output of above code:

Adding Items in Drawer
Here we are
- Adding on item click listener for Drawer item using onTap function.
- Adding Icon widget for Drawer item.
- Adding Text Widget for Drawer title.
- Closing Navigation Drawer programatically.
- Adding divider Widget after each drawer item (Line Divider).
Scaffold(
drawer: Drawer(
elevation: 20.0,
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
UserAccountsDrawerHeader(
accountName: Text('Hammad Tariq'),
accountEmail: Text('developine.com@gmail.com'),
currentAccountPicture:
Image.network('https://hammad-tariq.com/img/profile.png'),
decoration: BoxDecoration(color: Colors.blueAccent),
),
// Drawer layout first item.
ListTile(
leading: Icon(Icons.account_circle),
title: Text('Drawer layout Item 1'),
onTap: () {
// This line code will close drawer programatically....
Navigator.pop(context);
},
),
Divider(
height: 2.0,
),
],
)),
)
Adding Appbar (Toolbar) with Hamburger icon and Title

Simply add appBar using AppBar Widget and Flutter will make it like Toolbar and will also show hamburger icon.
If you want to center Appbar title use this property inside AppBar widget.
appBar: AppBar(
centerTitle: true,
title: Text('Developine App Bar'),
)
Hamburger icon is displayed by default because we have not provided any leading widget inside AppBar.
As our Scaffold widget has AppBar widget and our Drawer is inside AppBar so Flutter will place side menu icon (hamburger icon) automatically which will be used to open drawer.
If there is no drawer widget inside AppBar, Flutter will add back arrow here. which will be used to go back to screen or close app.
Completed Code
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Drawer Layout Demo',
debugShowCheckedModeBanner: false,
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(title: 'Flutter Drawer Demo Home Page'),
);
}
}
class MyHomePage extends StatelessWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return Container(
child: new Scaffold(
appBar: AppBar(
title: Text('Developine App Bar'),
)
drawer: Drawer(
elevation: 20.0,
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
UserAccountsDrawerHeader(
accountName: Text('Hammad Tariq'),
accountEmail: Text('developine.com@gmail.com'),
currentAccountPicture:
Image.network('https://hammad-tariq.com/img/profile.png'),
decoration: BoxDecoration(color: Colors.blueAccent),
),
ListTile(
leading: Icon(Icons.account_circle),
title: Text('Drawer layout Item 1'),
onTap: () {
// This line code will close drawer programatically....
Navigator.pop(context);
},
),
Divider(
height: 2.0,
),
ListTile(
leading: Icon(Icons.accessibility),
title: Text('Drawer layout Item 2'),
onTap: () {
Navigator.pop(context);
},
),
Divider(
height: 2.0,
),
ListTile(
leading: Icon(Icons.account_box),
title: Text('Drawer layout Item 3'),
onTap: () {
Navigator.pop(context);
},
)
],
)),
));
}
}
Adding Right Drawer in Flutter
If you want to open drawer from right side of app like below:

Code for Right Drawer layout:
This code has slight change than above code.
Above code is using drawer property of Scaffold Widget, whereas below code will be using endDrawer property of Scaffold Widget.
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Drawer Layout Demo',
debugShowCheckedModeBanner: false,
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(title: 'Flutter Drawer Demo Home Page'),
);
}
}
class MyHomePage extends StatelessWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return Container(
child: new Scaffold(
appBar: AppBar(
title: Text('Developine App Bar'),
)
endDrawer: Drawer(
elevation: 20.0,
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
UserAccountsDrawerHeader(
accountName: Text('Hammad Tariq'),
accountEmail: Text('developine.com@gmail.com'),
currentAccountPicture:
Image.network('https://hammad-tariq.com/img/profile.png'),
decoration: BoxDecoration(color: Colors.blueAccent),
),
ListTile(
leading: Icon(Icons.account_circle),
title: Text('Drawer layout Item 1'),
onTap: () {
// This line code will close drawer programatically....
Navigator.pop(context);
},
),
Divider(
height: 2.0,
),
ListTile(
leading: Icon(Icons.accessibility),
title: Text('Drawer layout Item 2'),
onTap: () {
Navigator.pop(context);
},
),
Divider(
height: 2.0,
),
ListTile(
leading: Icon(Icons.account_box),
title: Text('Drawer layout Item 3'),
onTap: () {
Navigator.pop(context);
},
)
],
)),
));
}
}
copyright : http://developine.com/
I know this site presents quality depending articles or reviews and extra material, is there any other website which gives these kinds of information in quality?
Outstanding quest there. What happened after?
Good luck!
You can definitely see your skills within the work you write.
The arena hopes for more passionate writers such as you who are
not afraid to mention how they believe. Always go after your heart.
It’s actually very complicated in this full of activity life to listen news on TV, therefore I only use the web for that reason, and get the
most up-to-date news.
This information is priceless. Where can I find out more?
If some one wishes expert view regarding blogging and site-building afterward i
suggest him/her to pay a quick visit this webpage, Keep
up the good job.
I got what you intend, appreciate it for putting up. Woh I am delighted
to find this website through google.
Thank you for the auspicious writeup. It in fact was a amusement account it.
Look advanced to far added agreeable from you! By the way, how can we communicate?
I every time emailed this blog post page to all my contacts, because if like to read it after that my contacts will too.
Hello.This article was really remarkable, especially since I was browsing
for thoughts on this topic last Tuesday.
You can definitely see your expertise in the article you write.
The world hopes for more passionate writers such as you who
are not afraid to say how they believe. Always go after your heart.
This text is invaluable. When can I find out more?
Wonderful website you have here but I was wondering if you knew
of any forums that cover the same topics discussed here?
I’d really like to be a part of group where I can get responses from other knowledgeable people that share the same
interest. If you have any recommendations, please let me know.
Cheers!
Its wonderful as your other blog posts :D, appreciate it for posting.
Hello.This article was really remarkable, especially since I was searching for thoughts on this matter
last Sunday.
Its fantastic as your other articles :D, regards for putting up.
I’m curious to find out what blog system you happen to be using?
I’m experiencing some minor security issues with my latest site and I’d
like to find something more risk-free. Do you have any solutions?
It’s actually a nice and useful piece of info.
I am satisfied that you shared this helpful info with
us. Please keep us informed like this. Thanks for sharing.
Can I just say what a comfort to discover somebody that truly understands what they are discussing over
the internet. You certainly understand how to bring an issue to light and
make it important. A lot more people must look at this and understand this
side of your story. It’s surprising you are
not more popular given that you most certainly have the gift.
Appreciating thе tіme andd effort you put
intfⲟ your sitе and in depth information yoᥙ offer.
It’s good to come across a blog every once in a while tһat isn’t thе same unwanted rehashed
information. Excellent read! I’ve bookmarked your site and I’m including your RSS feeԀs
to my Gooɡle account. https://syiedarossum.blogspot.com/
If you want to improve your knowledge simply
keep visiting this web page and be updated with
the hottest news update posted here.
Simply wish to say your article is as astounding.
The clarity on your put up is just excellent and that i could suppose you are knowledgeable in this
subject. Fine along with your permission allow me
to seize your RSS feed to keep updated with imminent post.
Thank you one million and please carry on the rewarding work.
If some one wishes to be updated with newest technologies then he must be pay
a visit this web page and be up to date everyday.