-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
c: regressionIt was better in the past than it is nowIt was better in the past than it is nowf: 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
- Run
flutter create bug. - Replace lib/main.dart with
import 'package:flutter/material.dart';
const homepage = '/';
const pageB = '/pageB';
const pageC = '/pageC';
const pageD = '/pageD';
final routes = <String, WidgetBuilder>{
homepage: (BuildContext context) => Homepage(),
pageB: (BuildContext context) => PageB(),
pageC: (BuildContext context) => PageC(),
pageD: (BuildContext context) => PageD(),
};
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
initialRoute: homepage,
routes: routes,
);
}
}
class Homepage extends StatelessWidget {
const Homepage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Homepage'),
),
body: Center(
child: FlatButton(
child: Text('Go to Page B'),
color: Colors.blue,
onPressed: () {
Navigator.pushNamed(context, pageB);
},
),
),
);
}
}
class PageB extends StatelessWidget {
const PageB({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Page B'),
),
body: Center(
child: FlatButton(
child: Text('Go to Page C'),
color: Colors.blue,
onPressed: () {
Navigator.pushNamed(context, pageC);
},
),
),
);
}
}
class PageC extends StatelessWidget {
const PageC({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Page C'),
),
body: Center(
child: FlatButton(
child: Text('Go to Page D and remove until Page B'),
color: Colors.blue,
onPressed: () {
Navigator.pushNamedAndRemoveUntil(
context, pageD, ModalRoute.withName(pageB));
},
),
),
);
}
}
class PageD extends StatelessWidget {
const PageD({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Page D'),
),
body: Center(
child: FlatButton(
child: Text('Go back to Page B'),
color: Colors.blue,
onPressed: () {
Navigator.pop(context);
},
),
),
);
}
}
- Run app and go until page D then go back to initial page
Expected results:
I'm expecting being able to go back to the initialRoute (homepage)
Actual results:
I'm only able to go back till Page B as calling pushNamedAndRemoveUntil seems to also have removed the initialRoute (homepage)
Logs
[✓] Flutter (Channel stable, v1.17.0, on Mac OS X 10.15.4 19E287, locale en-CN)
• Flutter version 1.17.0 at /Users/christophewang/dev/flutter
• Framework revision e6b34c2b5c (6 days ago), 2020-05-02 11:39:18 -0700
• Engine revision 540786dd51
• Dart version 2.8.1
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/christophewang/Library/Android/sdk
• Platform android-29, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.4.1, Build version 11E503a
• CocoaPods version 1.9.1
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[✓] VS Code (version 1.45.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.10.1
[✓] Connected device (1 available)
• iPhone Xʀ • AD185E2B-3525-49C1-A434-72B9CB85A2A1 • ios • com.apple.CoreSimulator.SimRuntime.iOS-12-2 (simulator)
• No issues found!
Moncader and beiger
Metadata
Metadata
Assignees
Labels
c: regressionIt was better in the past than it is nowIt was better in the past than it is nowf: 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.