initializer method
animation initializer
Implementation
void initializer(TickerProvider ticker) {
if (_controller != null) {
return;
}
_controller = AnimationController(
vsync: ticker,
duration: duration,
reverseDuration: reverseDuration,
value: initialValue,
lowerBound: lowerBound,
upperBound: upperBound,
animationBehavior: animationBehavior,
);
repeatStatusListenerListener = (status) {
if (status != AnimationStatus.completed &&
status != AnimationStatus.dismissed) {
_reverseCurvedAnimation = null;
return;
}
// if (repeats == null) {
// isAnimating = false;
// endAnimationListener?.call();
// return;
// }
if (skipDismissStatus) {
return;
}
repeatCount ??= repeats ?? 1;
if (repeatCount == 1) {
isAnimating = false;
if (animationEndFuture?.isCompleted == false) {
animationEndFuture!.complete();
animationEndFuture = null;
}
endAnimationListener?.call();
repeatCount = null;
WidgetsBinding.instance.scheduleFrameCallback((_) {
notify(); //TODO Check me. Used to trigger a rebuild after animation ends
});
} else {
if (status == AnimationStatus.completed) {
if (repeatCount! > 1) repeatCount = repeatCount! - 1;
if (shouldReverseRepeats) {
_controller!.reverse();
} else {
skipDismissStatus = true;
_controller!.value = lowerBound;
skipDismissStatus = false;
_controller!.forward();
}
} else if (status == AnimationStatus.dismissed) {
if (repeatCount! > 1) repeatCount = repeatCount! - 1;
if (shouldReverseRepeats) {
_controller!.forward();
} else {
skipDismissStatus = true;
_controller!.value = upperBound;
skipDismissStatus = false;
_controller!.reverse();
}
}
}
};
_controller!
..addListener(() {
snapValue = snapValue.copyToHasData(_controller!.value);
notify();
})
..addStatusListener(repeatStatusListenerListener);
onInitialized?.call(this);
if (shouldAutoStart) {
triggerAnimation();
}
}