Challenge - 5 Problems
Hero Animation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What happens when two Hero widgets have different tags?
Consider two screens each containing a Hero widget. The Hero on the first screen has tag 'hero1', and the Hero on the second screen has tag 'hero2'. What will happen when navigating between these screens?
Attempts:
2 left
💡 Hint
Hero animations require matching tags to link widgets across screens.
✗ Incorrect
Hero animations only work when the Hero widgets on both screens share the same tag. Different tags mean Flutter cannot match the widgets, so no animation occurs.
❓ lifecycle
intermediate2:00remaining
When does the Hero animation start during navigation?
At what point in the navigation lifecycle does the Hero animation begin when pushing a new route?
Attempts:
2 left
💡 Hint
Think about when Flutter can measure widget positions for animation.
✗ Incorrect
The Hero animation starts after both source and destination widgets are built and laid out so Flutter knows their positions to animate between them.
📝 Syntax
advanced2:00remaining
Identify the correct Hero widget usage
Which of the following Flutter code snippets correctly implements a Hero widget wrapping an Image with tag 'profilePic'?
Attempts:
2 left
💡 Hint
Check the order of parameters and tag type.
✗ Incorrect
Option A uses correct parameter order and a string tag. Option A has parameters reversed (though Flutter allows named parameters in any order, so B is valid). Option A uses an undefined variable profilePic instead of a string. Option A uses Image constructor incorrectly.
🔧 Debug
advanced2:00remaining
Why does this Hero animation cause a jump instead of smooth transition?
Given two screens with Hero widgets sharing the same tag, the animation jumps abruptly instead of smoothly transitioning. What is the most likely cause?
Flutter
Screen 1: Hero(tag: 'logo', child: Container(width: 100, height: 100, color: Colors.blue)) Screen 2: Hero(tag: 'logo', child: Container(width: 200, height: 200, color: Colors.blue))
Attempts:
2 left
💡 Hint
Hero animations can handle size changes but abrupt jumps usually mean size difference without smooth scaling.
✗ Incorrect
Different sizes between source and destination Hero widgets can cause the animation to jump if the transition is not smooth. Colors do not cause jumps, and tags are the same here. Material ancestor absence causes errors but not jumps.
🧠 Conceptual
expert2:00remaining
What is the role of FlightShuttleBuilder in Hero animations?
In Flutter's Hero widget, what does the FlightShuttleBuilder property control?
Attempts:
2 left
💡 Hint
Think about customizing the look of the Hero while it moves.
✗ Incorrect
FlightShuttleBuilder lets you customize the widget displayed during the Hero's transition animation, allowing different visuals than the source or destination widgets.