Reputation: 5254
I am trying to listen event for flutter reverse animation when it is completed but its not triggering for reverse just only for forward.
_animationController.addStatusListener((status) {
if (status == AnimationStatus.reverse &&
status == AnimationStatus.completed) {
print("Reverse Animation is completed");
}
});
Upvotes: 2
Views: 2693
Reputation: 5254
I also figured out another approach by myself.
_animationController.reverse().then((void) {
// Reverse animation completed
});
Upvotes: 3
Reputation: 886
First of all, status == AnimationStatus.reverse && status == AnimationStatus.completed
is always false. status
can't be equal to two values at the same time.
If you want to listen for when the animation / reverse animation is completed, use the following:
_animationController.addStatusListener((status) {
if (status == AnimationStatus.completed) {
// Animation completed
} else if (status == AnimationStatus.dismissed) {
// Reverse animation completed
}
});
Upvotes: 5