Learn/Navigation/Drawer Navigation

Drawer Navigation

Add a side navigation drawer for app-wide navigation

5 min~4 min read+30 FX

You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.

Table of Contents

  1. 1. Drawer Information Architecture
  2. 2. This Lesson In Simple Words
  3. 3. Your level focus
  4. 4. One practical habit
  5. 5. Deep Understanding Guide
  6. 6. Why this lesson matters
  7. 7. Study flow for better retention
  8. 8. Quick Glossary

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

Drawer Navigation

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.

dart
1// ── Adding a Drawer to Scaffold ──
2Scaffold(
3 appBar: AppBar(title: const Text('My App')),
4 // Scaffold provides hamburger icon automatically
5 drawer: Drawer(
6 child: ListView(
7 padding: EdgeInsets.zero,
8 children: [
9 // Header
10 const DrawerHeader(
11 decoration: BoxDecoration(color: Colors.blue),
12 child: Column(
13 crossAxisAlignment: CrossAxisAlignment.start,
14 mainAxisAlignment: MainAxisAlignment.end,
15 children: [
16 CircleAvatar(radius: 28, child: Icon(Icons.person, size: 28)),
17 SizedBox(height: 8),
18 Text('John Doe', style: TextStyle(color: Colors.white, fontSize: 16)),
19 Text('john@example.com', style: TextStyle(color: Colors.white70, fontSize: 12)),
20 ],
21 ),
22 ),
23 // Navigation items
24 ListTile(
25 leading: const Icon(Icons.home),
26 title: const Text('Home'),
27 onTap: () {
28 Navigator.pop(context); // close drawer
29 Navigator.pushReplacementNamed(context, '/home');
30 },
31 ),
32 ListTile(
33 leading: const Icon(Icons.settings),
34 title: const Text('Settings'),
35 onTap: () {
36 Navigator.pop(context);
37 Navigator.pushNamed(context, '/settings');
38 },
39 ),
40 const Divider(),
41 ListTile(
42 leading: const Icon(Icons.logout),
43 title: const Text('Logout'),
44 onTap: () => logout(context),
45 ),
46 ],
47 ),
48 ),
49 body: const Center(child: Text('App Content')),
50)

Close the Drawer First

💡 Close the Drawer First

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.

Drawer Information Architecture

A good drawer separates global sections from account actions:

  • top: identity and quick context
  • middle: primary and secondary destinations
  • bottom: risky actions like logout

Organized grouping improves discoverability and reduces mis-taps.

Drawer UX Checklist

  • Current destination is visually highlighted.
  • Tap targets are large and readable.
  • Navigation labels are short and unambiguous.
  • Logout and destructive actions are separated from routine navigation.

This Lesson In Simple Words

Add a side navigation drawer for app wide navigation. Navigation manages how users move between screens and return to previous states.

Your level focus

Connect each concept to real app features you can build.

One practical habit

Design route names and arguments before wiring screen UI.

Deep Understanding Guide

Why this lesson matters

Poor routing decisions create confusing UX and fragile deep-link behavior.

Study flow for better retention

  1. Map the lesson to one screen, one user action, and one expected output.
  2. Think user journey first: open app, enter data, recover state, continue flow.
  3. If you can choose between two approaches and explain why, you are improving.

Common Mistakes To Avoid

  • Passing very large objects through routes instead of IDs or lightweight models.
  • Mixing unrelated navigation methods in the same feature.
  • Losing state on back navigation due to poor route stack handling.
  • Not testing deep links and cold-start navigation paths.

Practice Sprint (15-25 Minutes)

  • Before running sample code, predict output and behavior in one sentence.
  • Implement a three-screen flow with named routes and typed arguments.
  • Add one deep-link path and verify expected destination.
  • Write a small route guard for authenticated vs guest users.
  • Complete the required exercises without using hints on the first attempt.
  • Answer this question out loud before checking quiz options: "Where do you add a Drawer in Flutter?".

Quick Glossary

  • context: A handle to widget location and inherited data in the tree.

Code Comprehension Drill

  • State the purpose of the code block in one line before reading details.
  • Mark inputs, state changes, and final output.
  • Change one small value and predict what should happen before running.
  • Run again and compare your prediction with actual behavior.

Lesson Completion Checklist

  • I can explain "Drawer Navigation" in simple words without reading notes.
  • I can describe one real app situation where this concept is required.
  • I know at least one mistake to avoid: Passing very large objects through routes instead of IDs or lightweight models.
  • I can modify one code sample and correctly predict the behavior change.
  • I can finish required exercises with understanding, not trial-and-error guesses.

Frequently Asked Questions

Where do you add a Drawer in Flutter?

Scaffold has a drawer property. Setting it automatically adds a hamburger menu icon to the AppBar.

How do you programmatically open the Drawer?

Scaffold.of(context).openDrawer() programmatically opens the drawer. The hamburger icon does this automatically.

What should you do before navigating from a Drawer ListTile?

Navigator.pop(context) closes the drawer (removes it from the route stack) before pushing a new screen.

Suggest Improvement

Something seems incorrect, unclear, or missing? Let us know.

About The Author

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