configAnimation method
void
configAnimation({
- required Duration delay,
- required bool animate,
- required bool manualTrigger,
- required bool infinite,
- Function? onFinish,
- dynamic controllerCallback(
- AnimationController controller
inherited
All the animations are controlled by a AnimationController The controller is created in the initState method of the parent AnimatedWidget This method controls the flow of the animation
Implementation
void configAnimation({
required Duration delay,
required bool animate,
required bool manualTrigger,
required bool infinite,
Function? onFinish,
Function(AnimationController controller)? controllerCallback,
}) {
/// If the user wants to check if the animation finished, we add a listener
if (onFinish != null) {
controller.addStatusListener((AnimationStatus status) {
if (status == AnimationStatus.completed) {
onFinish(AnimateDoDirection.forward);
} else if (status == AnimationStatus.dismissed) {
onFinish(AnimateDoDirection.backward);
}
});
}
/// If the user wants to trigger the animation manually, we expose the controller
if (!manualTrigger && animate) {
Future.delayed(delay, () {
if (disposed) return;
(infinite) ? controller.repeat() : controller.forward();
});
}
/// Returns the controller if the user requires it
if (controllerCallback != null) {
controllerCallback(controller);
}
}