-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
c: performanceRelates to speed or footprint issues (see "perf:" labels)Relates to speed or footprint issues (see "perf:" labels)customer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.
Description
Steps to Reproduce
Pages on Navigator stack rebuild when a new page is pushed onto the stack.
Suppose the pages were numbered numerically, in the order they are pushed onto the stack i.e. page 1 -> page 2 -> page 3. When we push Page 3, previous pages from page 1 to 2 rebuild as evident from the print statements. Is this a bug?
import 'package:flutter/material.dart';
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(id: 1),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.id}) : super(key: key);
final int id;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
print('Page ${widget.id} built!');
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.id.toString()),
),
body: new Center(
child: new RaisedButton(
child: new Text('Open next page'),
onPressed: () {
Navigator.of(context).push(
new MaterialPageRoute(
builder: (_) => new MyHomePage(id: widget.id + 1),
maintainState: true
)
);
}
)
),
);
}
}Logs
When page 2 is pushed, the log outputs
I/flutter (21176): Page 2 built!
I/flutter (21176): Page 2 built!
I/flutter (21176): Page 1 built!
Expected:
I/flutter (21176): Page 2 built! // only
When page 3 is pushed, the log outputs
I/flutter (21176): Page 2 built!
I/flutter (21176): Page 3 built!
I/flutter (21176): Page 3 built!
I/flutter (21176): Page 2 built!
I/flutter (21176): Page 1 built!
Expected:
I/flutter (21176): Page 3 built! // only
Flutter Doctor
[√] Flutter (on Microsoft Windows [Version 10.0.15063], locale en-US, channel master)
• Flutter at C:\Users\tzm\Downloads\flutter_sdk
• Framework revision b156a0f054 (5 days ago), 2017-08-11 22:01:40 -0700
• Engine revision fef7d827d6
• Tools Dart version 1.25.0-dev.9.0
[√] Android toolchain - develop for Android devices (Android SDK 25.0.3)
• Android SDK at C:\Users\tzm\AppData\Local\Android\sdk
• Platform android-26, build-tools 25.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)
cornelius-tan, amardeep, kerego, zoechi, na-fis and 71 morejlcool, S1r-Lanzelot, jonmaciel, dblokhin, Cayke and 7 more
Metadata
Metadata
Assignees
Labels
c: performanceRelates to speed or footprint issues (see "perf:" labels)Relates to speed or footprint issues (see "perf:" labels)customer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.