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);
}
My problem came from another async animation:
In
timerControllerList[index].stop();
is where I was stopping my first animation butawait finalMsgControllerList[index].forward()
was initiating another one.So if I clicked before finishing that second animation, it was creating the issue. Not sure why because the stop/check is running before but removing the
await
fixed my issue.