It’s often helpful to know when an animation changes state,
such as finishing, moving forward, or reversing.
You can get notifications for this with addStatusListener().
The following code modifies the previous example so that
it listens for a state change and prints an update.
The highlighted line shows the change:

..addStatusListener((status) => print('$status'));
    controller.forward();
  }
  // ...
}

Running this code produces this output:

AnimationStatus.forward
AnimationStatus.completed

Next, use addStatusListener() to reverse the animation
at the beginning or the end. This creates a “breathing” effect:

{animate2 → animate3}/lib/main.dart

@@ -35,7 +35,15 @@

35
35

void initState() {

36
36

super.initState();