Introduction to explicit animations with AnimationController
Notes
AnimationController
is a class that we can use to play an animation forward or in reverse,
- by default,
AnimationController
produces values that range from 0 to 1, during a given duration. AnimationController
generates a new value whenever Flutter needs to draw a new frame (using aTicker
)
Setting up an AnimationController
requires 5 steps:
- Create a
StatefulWidget
- add
SingleTickerProviderStateMixin
to theState
class - create a
late final AnimationController _animationController;
- initialize this
AnimationController
ininitState()
- Dispose it in the
dispose()
method
For an overview of how to reduce all the boilerplate code, see this tutorial:
7 comments