AnimationController

AnimationController is one of the most used Flutter animation classes. It is derived from Animation<double> class and adds some fundamental methods for manipulating animations. The Animation class is the basis of animation in Flutter; as said before, it does not have any animation control-related methods. AnimationController adds these controls to the animation concept, such as the following:

  • Play and stop controls: AnimationController adds the ability to play the animation forward, backward, or stop it
  • Duration: Real animations have a finite time to play, that is, they play for a while and finish, or repeat
  • Allows setting the animation current value: This causes a stop of the animation and notifies the status and value listeners
  • Allows defining the upper and lower bound of the animation: This is so that we can know the deemed values before and after playing the animation

Let's check the AnimationController constructor and analyze its main properties:

AnimationController({
double value,
Duration duration,
String debugLabel,
double lowerBound: 0.0,
double upperBound: 1.0,
AnimationBehavior animationBehavior: AnimationBehavior.normal,
@required TickerProvider vsync
})

As you can see, some properties are self-explanatory, but let's review them:

  • value: This is the initial value of the animation, and it defaults to lowerBound if not specified.
  • duration: This is the duration of the animation.
  • debugLabel: This is a string to help during debugging. It identifies the controller in debug output.
  • lowerBound: This cannot be null; it is the smallest value of the animation in which it is deemed to be dismissed, typically the start value when running.
  • upperBound: Also, this cannot be null; it is the largest value of the animation at which it is deemed to be complete, typically the end value when running.
  • animationBehavior: This configures how AnimationController behaves when animations are disabled. If it's AnimationBehavior.normal, the animation duration will be reduced, and if it's AnimationBehavior.preserveAnimationController will preserve its behavior.
  • vsync: This is a TickerProvider instance the controller will use to obtain a signal whenever a frame triggers.
Check all of the available methods for running animations with the AnimationController class: https://api.flutter.dev/flutter/animation/AnimationController-class.html.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.107.90