Complete the code to create an AnimationController with a duration of 2 seconds.
AnimationController controller = AnimationController(vsync: this, duration: Duration(seconds: [1]));The duration parameter sets how long the animation lasts. Here, 2 seconds is correct.
Complete the code to start the animation forward.
controller.[1]();reverse() which moves animation backward.stop() which halts the animation.The forward() method starts the animation moving forward.
Fix the error in disposing the AnimationController properly.
@override
void dispose() {
controller.[1]();
super.dispose();
}stop() instead of dispose().super.dispose().Always call dispose() on AnimationController to free resources.
Fill both blanks to create a Tween animation from 0.0 to 1.0 and animate it with the controller.
Animation<double> animation = Tween(begin: [1], end: [2]).animate(controller);
The Tween defines the range from 0.0 to 1.0 for the animation values.
Fill all three blanks to add a listener to the controller that calls setState, and then start the animation forward.
controller.addListener(() {
[1](() {
[2];
});
});
controller.[3]();dispose() instead of forward().setState.Use setState to update UI inside listener, optionally print a message, then start animation with forward().