Google Flutter Google Flutter Animations 2 — Questions and Answers
Question 1: Which Flutter widget interpolates its properties (color, size, padding) automatically over a given duration when they change?
- AnimatedBuilder
- TweenAnimationBuilder
- AnimatedContainer (Correct answer)
- ImplicitlyAnimatedWidget
Correct answer: AnimatedContainer
AnimatedContainer automatically animates changes to its decoration, size, alignment, and padding over the specified duration without requiring a controller.
Question 2: What class would you extend to create a custom implicitly animated widget in Flutter?
- StatefulWidget
- AnimatedWidget
- ImplicitlyAnimatedWidget (Correct answer)
- LeafRenderObjectWidget
Correct answer: ImplicitlyAnimatedWidget
Extending ImplicitlyAnimatedWidget gives you the built-in animation controller and tween machinery needed to animate between old and new property values.
Question 3: Which widget is the correct choice to animate a value to a new target without managing a controller yourself?
- AnimatedBuilder
- TweenAnimationBuilder (Correct answer)
- AnimatedSwitcher
- Hero
Correct answer: TweenAnimationBuilder
TweenAnimationBuilder drives an animation from a tween toward a target value and calls its builder on each frame, with no controller management required.
Question 4: When using AnimatedSwitcher, what determines how the old and new child widgets transition?
- The duration parameter only
- The transitionBuilder parameter (Correct answer)
- The Curves.linear default
- The key assigned to the children
Correct answer: The transitionBuilder parameter
AnimatedSwitcher's transitionBuilder callback wraps each child with a transition widget (e.g., FadeTransition), controlling how old and new children animate in and out.
Question 5: How does Flutter's Hero animation work between two routes?
- It copies the widget and fades between copies
- It shares a tagged widget and flies it between the source and destination screens (Correct answer)
- It uses a PageRouteBuilder with a custom transition
- It relies on AnimationController.repeat()
Correct answer: It shares a tagged widget and flies it between the source and destination screens
Hero matches widgets with the same tag across routes and animates the shared element from its position on the source page to its position on the destination page.
Question 6: What is the role of CurvedAnimation in Flutter?
- It stores begin and end values for a tween
- It wraps an animation and applies a non-linear Curve to its progress (Correct answer)
- It creates a looping animation automatically
- It synchronizes multiple animations to a single controller
Correct answer: It wraps an animation and applies a non-linear Curve to its progress
CurvedAnimation wraps a parent animation (usually an AnimationController) and maps its linear 0.0–1.0 progress through a Curve for non-linear easing.
Question 7: Which property of AnimationController sets how long a complete forward animation cycle takes?
- vsync
- lowerBound
- duration (Correct answer)
- upperBound
Correct answer: duration
The duration property of AnimationController defines the wall-clock time from lowerBound to upperBound during a forward() call.
Which Flutter widget interpolates its properties (color, size, padding) automatically over a given duration when they change?