Repository navigation
[go_router] Navigating back does not update router location since go_router 5.2.0 #115832
Description
Note: for version lower than 5.0.0 routing is working as expected.
Hi,
i have routes defined something like
GoRoute(
path: '/login',
name: loginRouteName,
pageBuilder: (context, state) => NoTransitionPage(
key: state.pageKey,
child: const LoginScreen(),
),
routes: [
GoRoute(
path: 'reset',
name: resetRouteName,
pageBuilder: (context, state) => NoTransitionPage(
key: state.pageKey,
child: const ResetEmailScreen(),
),],);
go_router_4.5.1.mp4
go_router_5.2.0.mp4
As you can see from video (go_router_5.2.0) when i go to subroute 'reset' and pop back to the 'login' route. the path is not changed and i cannot go to 'reset' route again. I am using goNamed() for navigation. The same issue is happening on all other platforms.
Flutter doctor
[✓] Flutter (Channel stable, 3.3.8, on macOS 12.5.1 21G83 darwin-x64, locale en-AE)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.72.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
Flutter doctor -v
[✓] Flutter (Channel stable, 3.3.8, on macOS 12.5.1 21G83 darwin-x64, locale en-AE)
• Flutter version 3.3.8 on channel stable at /Users/mac/Documents/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 52b3dc2 (13 days ago), 2022-11-09 12:09:26 +0800
• Engine revision 857bd6b74c
• Dart version 2.18.4
• DevTools version 2.15.0
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/mac/Library/Android/sdk
• Platform android-33, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14B47b
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.3)
• Android Studio at /Applications/Android Studio.app/Contents
• 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 11.0.13+0-b1751.21-8125866)
[✓] VS Code (version 1.72.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.52.0
[✓] Connected device (3 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 13 (API 33) (emulator)
• macOS (desktop) • macos • darwin-x64 • macOS 12.5.1 21G83 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 107.0.5304.110
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
huycozy commentedon Nov 23, 2022
Hi @abubakarmvp, please provide a completed and minimal reproducible code sample so that we may verify this. Thank you!
abubakarmvp commentedon Nov 23, 2022
Hi,
This is the minimal reproducible code.
Sample Code
ValentinVignal commentedon Nov 23, 2022
I can reproduce the issue with go_router 5.2.0
However, with the previous version (5.1.10), there is no issue. It looks like the regression was introduced in flutter/packages#2786
huycozy commentedon Nov 24, 2022
@abubakarmvp thanks for providing more information. And thank @ValentinVignal for reporting a working version.
This is a regression issue:
✅: No Issue ❌: Issue reproduced
Demo
5.1.10.mov
5.2.0.mov
Completed sample code
flutter doctor -v (stable and master)
[✓] Flutter (Channel stable, 3.3.8, on macOS 13.0 22A380 darwin-x64, locale en-VN) • Flutter version 3.3.8 on channel stable at /Users/huynq/Documents/GitHub/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 52b3dc25f6 (23 hours ago), 2022-11-09 12:09:26 +0800 • Engine revision 857bd6b74c • Dart version 2.18.4 • DevTools version 2.15.0 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/huynq/Library/Android/sdk • Platform android-33, build-tools 31.0.0 • ANDROID_HOME = /Users/huynq/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 14.0.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14A400 • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.3) • Android Studio at /Applications/Android Studio.app/Contents • 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 11.0.13+0-b1751.21-8125866) [✓] IntelliJ IDEA Community Edition (version 2022.2.2) • IntelliJ at /Applications/IntelliJ IDEA CE.app • Flutter plugin version 70.0.5 • Dart plugin version 222.4167.21 [✓] IntelliJ IDEA Community Edition (version 2022.1.1) • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app • 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 [✓] VS Code (version 1.73.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.52.0 [✓] Connected device (3 available) • iPhone 14 Pro Max (mobile) • 332079AF-E895-4685-910E-7B1E18B0C6B8 • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-0 (simulator) • macOS (desktop) • macos • darwin-x64 • macOS 13.0 22A380 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 107.0.5304.110 [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found!5 remaining items
haashem commentedon Nov 27, 2022
I have the same issue, open
named_routes.dartin example folder. run the app.Select a row, then pop back, select the same row. it will not go forward!

version 5.2.0
chunhtai commentedon Dec 1, 2022
maybe related #115962
VCasecnikovs commentedon Dec 5, 2022
Have the same issue
angjelkom commentedon Dec 6, 2022
I know we all spend our free time to contribute to these plugins and everyone is doing amazing job.
With that said its a bit worrying that the very basic (core) example of using go_router its broken. I know this is a main branch and stuff like this tend to happen but even so we are talking about a simple navigation being broken from a single commit.
Such commits should include better testing or we need better unit tests, as again even for a main branch as simple core feature shouldn't get broken, like a simple navigation in this case.
Apologize if this sounds too harsh but I'm just saying we should all pay attention more and yes this is our free time we are spending so its not a demand, rather than an advice.
With that said thanks again to all contributors, you are doing awesome job!
angjelkom commentedon Dec 6, 2022
@chunhtai found the cause the culprit is your pull #2786:
in the
_handleStateMayChangefunction which triggers router rebuild, you are accessing the new location via theuriproperty of the currentConfiguration of the router which is basically thelocationof therouteInformation.The problem here is that the
uriproperty doesn't get updated when the navigation is popped and that's because nothing triggersGoRouteInformationParserrebuild when popping the route (context.pop()), and when pushing a route (context.go()) a rebuild is triggered onGoRouteInformationParserwhich reflects the change.So the location stays same when checking in
_handleStateMayChangeso rebuild on the GoRouter doesn't get triggered, and when we try to go to the same route again this part of theGoRouteInformationProviderignores it:Hope this gives you an idea how to add a quick fix.
konnic commentedon Dec 8, 2022
@chunhtai thanks a lot for the quick fix, this helps a lot!
I just tried it out and was wondering one thing. When popping a page from e.g.
/resource/subthe updated URL is/resource/. I would've expected that the updated URL would be/resourcewithout the trailing slash.Would you consider this a bug? If yes, I'm happy to open up an issue.
chunhtai commentedon Dec 8, 2022
@konnic yes, please file a bug and pin me on it.
github-actions commentedon Mar 5, 2023
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.