Optimizing animations
In this recipe, you will use AnimatedBuilder widgets, which simplify the process of writing animations and provide some important performance optimizations.
In particular, you will design a “yo-yo-like” animation. By using an AnimatedBuilder, your animations will only need to redraw the descendants of the widget. In this way, you will both optimize the animations and simplify the process of designing them.
Getting ready
To follow along with this recipe, you need the app built in the previous three recipes: Designing animations part 1 — VSync and the AnimationController, Designing animations part 2 — Adding multiple animations, and Designing animations part 3 — Using curves.
How to do it...
You will now add an AnimatedBuilder widget to your app to optimize the movement of the ball on the screen:
- In the
buildmethod of the_ShapeAnimationStateclass, remove theactionsparameter from theAppBar. ...