Repository: flutter
Issue: AnimationStatus doesn't change if user navigates to a new page
Labels: framework,a: animation,f: routes,has reproducible steps,P2,found in release: 3.0,found in release: 3.1,team-framework,triaged-framework

If you trigger an animation and wait for the `AnimationStatus` to update in a callback, the `AnimationStatus` will never get updated, unless you go back to that page, then it will get updated immediately.

I believe this happens because the ticker provided by `SingleTickerProviderStateMixin` will stop ticking once that branch of the widget tree gets marked as inactive by the framework, and the `AnimationController` `_tick` method isn't called anymore (and this method updates the `AnimationStatus`).

I can't find this behavior documented anywhere, if this is the desired behavior so I think it should be documented on the `addStatusListener` method and the variations of `AnimationLocalStatusListenersMixin`, since most people just use `SingleTickerProviderStateMixin`.

We caught this by subscribing for `AnimationStatus` updates, so we can reverse an animation once they are done (imagine a notification appearing and the disappearing). If the user navigates during the animation `forward` phase, then when she comes back later, she will see the `reverse` phase animation starting, which is really undesired, as this animation should have completed an hour a go.

In case someone needs a solution, we created our own ticker to keep the animation always going for this particular widget.



<details>
  <summary>Here's a minimum reproducible example</summary>

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Animation Status MRE'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
  late final controller = AnimationController(vsync: this, duration: const Duration(seconds: 5));
  late final animation = Tween<double>(begin: 0, end: 5).animate(controller)..addStatusListener(_animationStatusListener);

  void _animationStatusListener(AnimationStatus status) {
    print('New animation status: $status');

    if (status == AnimationStatus.completed) {
      print('reversing animation');
      controller.reverse();
    }
  }

  void _navigateAndAnimate() {
    controller.forward();
    Navigator.push(context, MaterialPageRoute(builder: (context) => const SecondPage()));
  }


  @override
  void dispose() {
    controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            AnimatedBuilder(
              animation: animation,
              builder: (context, child) {
                return Text(
                  animation.value.toStringAsFixed(2),
                  style: Theme.of(context).textTheme.headline4,
                );
              },
            ),
            const SizedBox(height: 16),
            ElevatedButton(onPressed: _navigateAndAnimate, child: const Text('Navigate')),
          ],
        ),
      ),
    );
  }
}

class SecondPage extends StatelessWidget {
  const SecondPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Second page'),
      ),
      body: const Center(
        child: Padding(
          padding: EdgeInsets.all(24),
          child: Text('Go back after 5 seconds to see how the animation is triggered only on pop'),
        ),
      ),
    );
  }
}
```
</details>