buildAnimation method

void buildAnimation({
  1. required Duration delay,
  2. required bool animate,
  3. required bool manualTrigger,
  4. required bool infinite,
  5. Function? onFinish,
  6. dynamic controllerCallback(
    1. AnimationController controller
    )?,
})
inherited

Implementation

void buildAnimation({
  required Duration delay,
  required bool animate,
  required bool manualTrigger,
  required bool infinite,
  Function? onFinish,
  Function(AnimationController controller)? controllerCallback,
}) {
  /// Launch the animation ASAP or wait until needed
  if (animate && !manualTrigger) {
    Future.delayed(delay, () {
      if (disposed) return;
      if (infinite) {
        controller.repeat();
        return;
      }

      (animate) ? controller.forward() : controller.reverse();
    });
  }

  /// If the animation already happen, we can animate it back
  if (!animate) {
    if (disposed) return;
    if (infinite) {
      controller.stop();
      return;
    }
    controller.animateBack(0);
  }
}