This may sound simple but I’m referring about checking it after calling stop()
. For example:
if (timerControllerList[index].isAnimating) {
await timerControllerList[index].stop();
}
if (timerControllerList[index].status == AnimationStatus.forward) {
// it goes in :(
}
I have 2 timer animations (that’s why I have a List
with them) that I can pause independently before reaching 10 seconds and I need to detect when pausing any of them, that the other is also stopped. In this case all of them have a status forward
.
Initialization:
void initTimer(int index) {
// called from initState()
late AnimationController timerController;
late Animation<int> timerAnimation;
int timerCounter = 10;
timerController = AnimationController(
vsync: this,
duration: Duration(seconds: timerCounter),
);
timerAnimation =
StepTween(begin: 0, end: timerCounter * 1000).animate(timerController)
..addStatusListener((status) {
if (status == AnimationStatus.completed) {
stopTimer(index);
}
});
timerControllerList.add(timerController);
timerAnimationList.add(timerAnimation);
}
2
Answers
This is how I check the status of an animation on my splash screen.
You could use listeners to help you with that.
This would check if it is stopped:
or to check if it is paused something like this:
or even: