Where do you add a Drawer in Flutter?
Scaffold has a drawer property. Setting it automatically adds a hamburger menu icon to the AppBar.
Add a side navigation drawer for app-wide navigation
Passing the Quiz & Exercises is mandatory to earn FX and proceed. If you fail, try again to gain the required FX, then the Proceed button will become available.
You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.
Having trouble? AI is here to help
Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.
Use the AI button at the bottom of the screen
A Drawer is a panel that slides in from the side, usually the left. It is commonly used for app-wide navigation links, profile info, and settings. When you add a Drawer to a Scaffold, Flutter automatically shows a hamburger menu icon in the AppBar.
1// ── Adding a Drawer to Scaffold ──2Scaffold(3appBar: AppBar(title: const Text('My App')),4// Scaffold provides hamburger icon automatically5drawer: Drawer(6child: ListView(7padding: EdgeInsets.zero,8children: [9// Header10const DrawerHeader(11decoration: BoxDecoration(color: Colors.blue),12child: Column(13crossAxisAlignment: CrossAxisAlignment.start,14mainAxisAlignment: MainAxisAlignment.end,15children: [16CircleAvatar(radius: 28, child: Icon(Icons.person, size: 28)),17SizedBox(height: 8),18Text('John Doe', style: TextStyle(color: Colors.white, fontSize: 16)),19Text('john@example.com', style: TextStyle(color: Colors.white70, fontSize: 12)),20],21),22),23// Navigation items24ListTile(25leading: const Icon(Icons.home),26title: const Text('Home'),27onTap: () {28Navigator.pop(context); // close drawer29Navigator.pushReplacementNamed(context, '/home');30},31),32ListTile(33leading: const Icon(Icons.settings),34title: const Text('Settings'),35onTap: () {36Navigator.pop(context);37Navigator.pushNamed(context, '/settings');38},39),40const Divider(),41ListTile(42leading: const Icon(Icons.logout),43title: const Text('Logout'),44onTap: () => logout(context),45),46],47),48),49body: const Center(child: Text('App Content')),50)
Always call `Navigator.pop(context)` before navigating, to close the drawer before pushing a new screen. Otherwise the drawer stays open on the new screen.
A good drawer separates global sections from account actions:
Organized grouping improves discoverability and reduces mis-taps.
Add a side navigation drawer for app wide navigation. Navigation manages how users move between screens and return to previous states.
Connect each concept to real app features you can build.
Design route names and arguments before wiring screen UI.
Poor routing decisions create confusing UX and fragile deep-link behavior.
Scaffold has a drawer property. Setting it automatically adds a hamburger menu icon to the AppBar.
Scaffold.of(context).openDrawer() programmatically opens the drawer. The hamburger icon does this automatically.
Navigator.pop(context) closes the drawer (removes it from the route stack) before pushing a new screen.
Something seems incorrect, unclear, or missing? Let us know.
FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.
Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.
Sign in to continue with exercises and quiz for this lesson.
Sign In to Continue