Repository: flutter
Issue: why a page with statefull is rebuild every time when the global route change?
Labels: framework,c: performance,d: api docs,f: routes,P2,team-framework,triaged-framework

### what

this is my [code](https://github.com/dumplings/flutter-demo/tree/master/life_cycle).  
i make 5 pages, one is extends stateless, others statefull, and Their relationship is `push` or `pop` to next one,  and i found out something is that if i go next page, old will be rebuild, even how old page(just statefull page will happened), I know that using statefull at the root is a matter of performance and is not recommended, I just want to know why this happened. thank you.

### example code
#### main.js
```dart
    return MaterialApp(
      ...
      initialRoute: '/',
      routes: {
        '/': (_) => HomePage(),
        '/half': (_) => HomeHalfPage(),
        '/first': (_) => FirstPage(),
        '/second': (_) => SecondPage(),
        '/third': (_) => ThirdPage(),
      },
    );
```

#### body.js
```dart
// Created by hejingguo on 2019-08-06
import 'package:flutter/material.dart';

class Body extends StatelessWidget {
  final String title;
  final String routeName;
  final bool isEnd;

  Body(this.title, this.routeName, {this.isEnd = false});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(title),
            Padding(
              padding: EdgeInsets.only(
                top: 30.0,
              ),
            ),
            RaisedButton(
              onPressed: () {
                if (isEnd) {
                  Navigator.pop(context);
                } else {
                  Navigator.pushNamed(context, routeName);
                }
              },
              child: Text('go to $routeName'),
            ),
          ],
        ),
      ),
    );
  }
}
```

#### page.js
```dart
import 'package:flutter/material.dart';

import 'body.dart';

void printMessage(String methodName) =>
    print('Home Page ===${DateTime.now().toUtc()}===> $methodName');

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  void initState() {
    super.initState();
    printMessage('initState');
  }

  @override
  void dispose() {
    super.dispose();
    printMessage('dispose');
  }

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    printMessage('didChangeDependencies');
  }

  @override
  void didUpdateWidget(HomePage oldWidget) {
    super.didUpdateWidget(oldWidget);
    printMessage('didUpdateWidget');
  }

  @override
  Widget build(BuildContext context) {
    printMessage('build');
    return Body('HomePage', '/half');
  }
}
```
#### log
```shell
flutter: Home Page ===2019-08-06 03:14:21.585795Z===> initState
flutter: Home Page ===2019-08-06 03:14:21.587966Z===> didChangeDependencies
flutter: Home Page ===2019-08-06 03:14:21.588262Z===> build
flutter: Home Page ===2019-08-06 03:14:21.854595Z===> didUpdateWidget
flutter: Home Page ===2019-08-06 03:14:21.854860Z===> build
flutter: Home Half Page ===2019-08-06 03:14:24.351334Z===> build
flutter: Home Page ===2019-08-06 03:14:24.666594Z===> build
flutter: First Page ===2019-08-06 03:14:25.497391Z===> initState
flutter: First Page ===2019-08-06 03:14:25.497650Z===> didChangeDependencies
flutter: First Page ===2019-08-06 03:14:25.497916Z===> build
flutter: Home Page ===2019-08-06 03:14:25.820592Z===> build
flutter: Second Page ===2019-08-06 03:14:29.350101Z===> initState
flutter: Second Page ===2019-08-06 03:14:29.350341Z===> didChangeDependencies
flutter: Second Page ===2019-08-06 03:14:29.350547Z===> build
flutter: Home Page ===2019-08-06 03:14:29.657926Z===> build
flutter: First Page ===2019-08-06 03:14:29.660035Z===> build
flutter: Third Page ===2019-08-06 03:14:32.350773Z===> initState
flutter: Third Page ===2019-08-06 03:14:32.351007Z===> didChangeDependencies
flutter: Third Page ===2019-08-06 03:14:32.351208Z===> build
flutter: First Page ===2019-08-06 03:14:32.661122Z===> build
flutter: Second Page ===2019-08-06 03:14:32.663558Z===> build
flutter: Home Page ===2019-08-06 03:14:32.665463Z===> build
```

[more code](https://github.com/dumplings/flutter-demo/tree/master/life_cycle)


### Flutter Version
Flutter 1.7.8+hotfix.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 20e59316b8 (3 weeks ago) • 2019-07-18 20:04:33 -0700
Engine • revision fee001c93f
Tools • Dart 2.4.0