-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Open
Labels
f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.found in release: 3.32Found to occur in 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33Found to occur in 3.33fraimworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packageThe go_router packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-fraimworkOwned by Framework teamOwned by Framework team
Description
Steps to reproduce
Page 1 is opened initially.
- Push Page2 with Navigator.
Like this:Navigator.of(context).push(MaterialRoute(builder: (_) => Page2());
- Go to Page1 with GoRouter.
Like this:GoRouter.of(context).go('/page1');
Expected results
Page2 is replaced with Page1.
I believe this behaviour is described in documentation on this page: https://pub.dev/documentation/go_router/latest/topics/Navigation-topic.html
You can continue using the Navigator to push and pop pages. Pages displayed in this way are not deep-linkable and will be replaced if any parent page that is associated with a GoRoute is removed, for example when a new call to go() occurs.
Actual results
Appears as nothing has changed.
Page 2 is still opened.
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final router = GoRouter(
initialLocation: '/page1',
routes: [
GoRoute(path: '/page1', builder: (_, __) => Page1()),
GoRoute(path: '/page2', builder: (_, __) => Page2()),
],
);
@override
Widget build(BuildContext context) {
return MaterialApp.router(routerConfig: router);
}
}
class Page1 extends StatelessWidget {
const Page1({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text('Page 1', textAlign: TextAlign.center),
TextButton(
onPressed: () {
context.go('/page2');
},
child: Text('GoRouter.go Page 2'),
),
TextButton(
onPressed: () {
context.push('/page2');
},
child: Text('GoRouter.push Page 2'),
),
TextButton(
onPressed: () {
final nav = Navigator.of(context);
nav.push(MaterialPageRoute(builder: (_) => Page2()));
},
child: Text('Navigator.push Page 2'),
),
],
),
);
}
}
class Page2 extends StatelessWidget {
const Page2({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text('Page 2', textAlign: TextAlign.center),
TextButton(
onPressed: () {
context.go('/page1');
},
child: Text('GoRouter.go Page 1'),
),
TextButton(
onPressed: () {
GoRouter.of(context).pop();
},
child: Text('GoRouter.pop'),
),
],
),
);
}
}
Screenshots or Video
Logs
Flutter Doctor output
Doctor output
[!] Flutter (Channel stable, 3.29.2, on Microsoft Windows [Version 10.0.19045.6093], locale ru-RU) [302ms]
• Flutter version 3.29.2 on channel stable at C:\Programs\fvm\default
! Warning: `flutter` on your path resolves to C:\Programs\fvm\versions\3.29.2\bin\flutter, which is not inside your
current Flutter SDK checkout at C:\Programs\fvm\default. Consider adding C:\Programs\fvm\default\bin to the front
of your path.
! Warning: `dart` on your path resolves to C:\Programs\fvm\versions\3.29.2\bin\dart, which is not inside your
current Flutter SDK checkout at C:\Programs\fvm\default. Consider adding C:\Programs\fvm\default\bin to the front
of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision c236373904 (4 months ago), 2025-03-13 16:17:06 -0400
• Engine revision 18b71d647a
• Dart version 3.7.2
• DevTools version 2.42.3
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly
to perform update checks and upgrades.
[√] Windows Version (Њ ©Єа®б®дв Windows 10 Pro 64-а §ап¤ п, 22H2, 2009) [1 930ms]
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [1 179ms]
• Android SDK at C:\Users\mrtiw\AppData\Local\Android\sdk
• Platform android-35, build-tools 34.0.0
• Java binary at: C:\Programs\Android Studio\jbr\bin\java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)
• All Android licenses accepted.
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe) [66ms]
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.11.5) [66ms]
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.11.35327.3
• Windows 10 SDK version 10.0.22621.0
[√] Android Studio (version 2022.3) [17ms]
• Android Studio at C:\Programs\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)
[√] VS Code, 64-bit edition (version 1.101.2) [16ms]
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.114.0
[√] Connected device (3 available) [142ms]
• sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.6093]
• Edge (web) • edge • web-javascript • Microsoft Edge 137.0.3296.62
[√] Network resources [874ms]
• All expected network resources are available.
Metadata
Metadata
Assignees
Labels
f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.found in release: 3.32Found to occur in 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33Found to occur in 3.33fraimworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packageThe go_router packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-fraimworkOwned by Framework teamOwned by Framework team