Tween and AnimationController classes
on Friday, 24th of July, 2020
All Flutter Animations need two things:
An AnimationController. This controller has two important purposes. First, it defines how long the animation will last via it's
durationproperty. It's other purpose is to provide a handful of methods that tell the animation how to behave. i.e.
Tweenis short for 'in between', and it represents the value of the property changing in between frames. For example, if you're animating the opacity of a container from 0.0 to 1.0, your tween will represent the values at
0.2, and so on.
You set up Tweens by creating new Tween class and passing the starting and
ending values. In the opacity example, because opacity values are
you'd do something like this:
Tween<double> tween = new Tween<double>(begin: 0.0, end: 1.0); // then you'd animate it, but more on that in a bit
But if you wanted to animate from blue to green, Flutter Tweens can do that too:
ColorTween colorTween = new ColorTween( begin: Colors.blue, end: Colors.green, ); // then you'd animate it, but more on that in bit.
The point is, Tween's return values at periods between start and finish, which you can pass as props to whatever you're animating, so it's always getting updated.
In the next lesson, we'll see an example of using these classes.