Challenge - 5 Problems
Drawer Navigation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate1:30remaining
What happens when you tap a Drawer item?
In a Flutter app with a Drawer containing navigation items, what is the typical behavior when a user taps an item inside the Drawer?
Attempts:
2 left
💡 Hint
Think about how navigation usually works with side menus in mobile apps.
✗ Incorrect
When a user taps a Drawer item, the Drawer typically closes and the app navigates to the selected screen to provide a smooth user experience.
❓ lifecycle
intermediate1:30remaining
When is the Drawer widget built in Flutter?
At what point in the widget lifecycle is the Drawer widget built in a Flutter Scaffold?
Attempts:
2 left
💡 Hint
Consider how Flutter builds widgets in the widget tree.
✗ Incorrect
The Drawer widget is part of the Scaffold's widget tree and is built every time the Scaffold rebuilds, even if the Drawer is not visible.
advanced
2:00remaining
What is the correct way to close the Drawer programmatically?
In Flutter, if you want to close the Drawer from inside a Drawer item tap handler, which code snippet correctly closes the Drawer?
Flutter
Scaffold.of(context).???;
Attempts:
2 left
💡 Hint
Think about how to close routes or overlays in Flutter.
✗ Incorrect
The Drawer is a route on top of the main screen. Calling Navigator.of(context).pop() closes the Drawer by popping that route.
📝 Syntax
advanced2:00remaining
Identify the error in this Drawer code snippet
What error will this Flutter Drawer code cause?
Drawer(
child: ListView(
children: [
ListTile(
title: Text('Home'),
onTap: () {
Navigator.pushNamed(context, '/home');
}
),
],
),
);
Attempts:
2 left
💡 Hint
Think about what happens if you navigate without closing the Drawer.
✗ Incorrect
If you navigate without closing the Drawer, the Drawer remains open on top of the new screen, causing UI issues.
🧠 Conceptual
expert2:30remaining
Why use a GlobalKey with Drawer?
In Flutter, why might you use a GlobalKey to control the Drawer instead of calling Scaffold.of(context)?
Attempts:
2 left
💡 Hint
Think about widget context and accessing ScaffoldState from different parts of the app.
✗ Incorrect
GlobalKey lets you access the ScaffoldState from anywhere, even if the widget context is not a descendant of Scaffold, enabling Drawer control.