Challenge - 5 Problems
Navigator Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What happens after Navigator.push is called?
In a Flutter app, when you call Navigator.push(context, MaterialPageRoute(builder: (context) => NewPage())), what is the immediate visible effect on the app UI?
Flutter
Navigator.push(context, MaterialPageRoute(builder: (context) => NewPage()));
Attempts:
2 left
💡 Hint
Think about what 'push' means in navigation stacks.
✗ Incorrect
Navigator.push adds a new page on top of the current stack, so the new page appears on screen.
❓ ui_behavior
intermediate2:00remaining
What is the effect of Navigator.pop(context)?
In Flutter, what happens when Navigator.pop(context) is called on a page that was pushed onto the stack?
Flutter
Navigator.pop(context);
Attempts:
2 left
💡 Hint
Pop means to remove the top page from the stack.
✗ Incorrect
Navigator.pop removes the current route, revealing the one below it.
❓ lifecycle
advanced2:00remaining
What lifecycle method is called when a page is popped?
When you call Navigator.pop(context) to close a page in Flutter, which lifecycle method of the popped page is called just before it disappears?
Attempts:
2 left
💡 Hint
Think about cleaning up resources when a widget is removed.
✗ Incorrect
dispose() is called when a StatefulWidget is removed from the widget tree, such as when popped.
advanced
2:00remaining
What is the result of this Navigator.push call with await?
Consider this Flutter code snippet:
final result = await Navigator.push(context, MaterialPageRoute(builder: (context) => InputPage()));
What does the variable 'result' contain after the pushed page is popped?
Flutter
final result = await Navigator.push(context, MaterialPageRoute(builder: (context) => InputPage()));Attempts:
2 left
💡 Hint
Navigator.push returns a Future that completes when the page is popped.
✗ Incorrect
Navigator.push returns a Future that resolves to the value passed to pop on the pushed page.
🔧 Debug
expert2:00remaining
Why does this Navigator.pop call cause an error?
Given this Flutter code inside a widget:
Navigator.pop();
Why might this cause a runtime error?
Attempts:
2 left
💡 Hint
Navigator methods usually need context to find the right navigator.
✗ Incorrect
Navigator.pop requires the BuildContext to find the Navigator in the widget tree to pop the current route.