Google Flutter Google Flutter Animations 1 — Questions and Answers
Question 1: Which class in Flutter is the foundation for all animation objects and holds a value that changes over time?
- AnimationController
- Animation<double> (Correct answer)
- Tween
- CurvedAnimation
Correct answer: Animation<double>
Animation<double> is the abstract base class that holds a value changing over time and notifies listeners of state changes.
Question 2: What is the primary purpose of an AnimationController in Flutter?
- To define the start and end values of an animation
- To apply easing curves to an animation
- To control the playback, duration, and direction of an animation (Correct answer)
- To rebuild the widget tree on every animation frame
Correct answer: To control the playback, duration, and direction of an animation
AnimationController controls the animation's duration, playback direction (forward/reverse), and can start, stop, or repeat the animation.
Question 3: Which widget automatically rebuilds itself whenever an Animation's value changes?
- AnimatedContainer
- AnimationBuilder
- AnimatedBuilder (Correct answer)
- AnimatedWidget
Correct answer: AnimatedBuilder
AnimatedBuilder takes an Animation and a builder callback, rebuilding only the widget subtree inside builder whenever the animation ticks.
Question 4: What does a Tween<double>(begin: 0.0, end: 1.0).animate(controller) return?
- A Tween object
- An AnimationController
- An Animation<double> (Correct answer)
- A CurvedAnimation
Correct answer: An Animation<double>
Tween.animate() chains the tween to a parent animation and returns an Animation<double> whose value interpolates between begin and end.
Question 5: Which Curve constant produces an animation that overshoots the target and then settles back?
- Curves.easeIn
- Curves.bounceOut
- Curves.elasticOut (Correct answer)
- Curves.elasticIn
Correct answer: Curves.elasticOut
Curves.elasticOut creates a spring-like overshoot effect where the value exceeds the target before settling, simulating elastic snap.
Question 6: What must you always call on an AnimationController when the owning State object is disposed?
- controller.stop()
- controller.reset()
- controller.dispose() (Correct answer)
- controller.forward()
Correct answer: controller.dispose()
Calling controller.dispose() releases the vsync ticker and prevents memory leaks when the State is removed from the tree.
Question 7: Which mixin should a State class use to provide a vsync to an AnimationController?
- AutomaticKeepAliveClientMixin
- SingleTickerProviderStateMixin (Correct answer)
- WidgetsBindingObserver
- RestorationMixin
Correct answer: SingleTickerProviderStateMixin
SingleTickerProviderStateMixin implements TickerProvider, supplying the single ticker vsync that AnimationController requires to schedule frame callbacks.
Which class in Flutter is the foundation for all animation objects and holds a value that changes over time?