Repository: flutter
Issue: Can not avoid calling didChangeDependencies on widget destruction when using routes and ModalRoute.of()
Labels: c: new feature,framework,f: routes,c: proposal,P3,team-framework,triaged-framework

## Steps to Reproduce

<!-- You must include full steps to reproduce so that we can reproduce the problem. -->

1. Run `flutter create bug`.
2. Update the files as follows: 
Replace the main.dart contents:

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      initialRoute: '/',
      routes: {
        '/': (context) => Scaffold(
              appBar: AppBar(title: Text('Screen 1')),
              body: FirstScreen(),
            ),
        '/route': (context) => Scaffold(
              appBar: AppBar(title: Text('Screen 2')),
              body: SecondScreen(),
            ),
      },
    );
  }
}

class FirstScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: RaisedButton(
        child: Text('Launch screen'),
        onPressed: () {
          Navigator.pushNamed(context, '/route');
        },
      ),
    );
  }
}

class SecondScreen extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return SecondScreenState();
  }
}

class SecondScreenState extends State<SecondScreen> {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: RaisedButton(
        onPressed: () {
          Navigator.pop(context);
        },
        child: Text('Go back!'),
      ),
    );
  }

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    ModalRoute.of(context);
  }
}
```
3. Set a breakpoint on the `SecondScreenState.didChangeDependencies()` method.
4. Run app.
5. Navigate to the screen 2.
6. The breakpoint will be hit.
6. Navigate back. 
7. The breakpoint will be hit again.

**Expected results:** 
I expect a way to determine that this widget is going to be destroyed as navigation is going away to a different route. This allows avoiding calling data load routines that require a context. 


**Actual results:**
Currently, there's no way to determine the fact that the widget is going to be destroyed and the route associated with it has been changed. I can see the changed route in the debugger in the `ModalRoute.of(context).navigator._lastAnnouncedRouteName` property. I could compare the new route and the route associated with the widget if having access to this property. But there's no such possibility. 

For example, the only way to determine the presence of route params in a widget is to call `ModalRoute.of(context).settings.arguments`. This call requires a build context and can not be performed in the `initState()` method. Thus, loading data may only be performed in the `didChangeDependencies` method. The `ModalRoute.of(context)` call adds the widget to the list of `ModalRoute` dependencies and `didChangeDependencies` is called on route change.

As a result, in my real application, I can not avoid unneeded API calls on the widget unload. Moreover, if I make an async API call (any API call actually) then it finishes when the build context of the widget is already disposed and can not be used, I'm getting an exception that `setState` is called on a disposed context.

It would be nice to add a possibility to determine the fact that navigation is changed and the current widget is going to be disposed in the `didChangeDependencies` method due to route change.