extension GoRouterExt on GoRouter {
String get _currentRoute => routerDelegate.currentConfiguration.matches.last.matchedLocation;
void popToIndex(int index) {
int currentIndex = routerDelegate.currentConfiguration.matches.length - 1;
while (routerDelegate.currentConfiguration.matches.length > index) {
if (!canPop() || currentIndex == index) {
return;
}
pop();
currentIndex--;
}
}
void popUntilPath(String ancestorPath) {
while (_currentRoute != ancestorPath) {
if (!canPop()) {
return;
}
pop();
}
}
}
use it like GoRouter.of(context).popUntilPath(thePath);
Expected results
pop until "thePath"
Actual results
void popUntilPath(String ancestorPath) {
while (_currentRoute != ancestorPath) {
if (!canPop()) {
return;
}
pop(); // this pop() seems not working as it should
}
}
the pop() is not working properly, so stuck in this while loop.
this was working in Go_Router 13.2.5, but not after v14
Code sample
Code sample
```dart
extension GoRouterExt on GoRouter {
String get _currentRoute => routerDelegate.currentConfiguration.matches.last.matchedLocation;
void popToIndex(int index) {
int currentIndex = routerDelegate.currentConfiguration.matches.length - 1;
while (routerDelegate.currentConfiguration.matches.length > index) {
if (!canPop() || currentIndex == index) {
return;
}
pop();
currentIndex--;
}
}
void popUntilPath(String ancestorPath) {
while (_currentRoute != ancestorPath) {
if (!canPop()) {
return;
}
pop();
}
}
}
```
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
```console
[Paste your logs here]
```
Flutter Doctor output
Doctor output
```console
[✓] Flutter (Channel stable, 3.22.0, on macOS 14.5 23F79 darwin-arm64, locale zh-Hant-TW)
• Flutter version 3.22.0 on channel stable at /Users/shaynechang/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5dcb86f68f (4 months ago), 2024-05-09 07:39:20 -0500
• Engine revision f6344b75dc
• Dart version 3.4.0
• DevTools version 2.34.3
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
• Android SDK at /Users/shaynechang/Library/Android/sdk
• Platform android-35, build-tools 35.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.1)
• 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 17.0.10+0-17.0.10b1087.21-11609105)
[✓] VS Code (version 1.92.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.94.0
[✓] Connected device (5 available)
• sdk gphone16k arm64 (mobile) • emulator-5554 • android-arm64 • Android 15 (API 35) (emulator)
• iPhone 15 (mobile) • C26EED6F-3C29-4D42-81CD-4535632B3A69 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.5 23F79 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.5 23F79 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.120
[✓] Network resources
• All expected network resources are available.
• No issues found!
```
Steps to reproduce
Create an extension on GoRouter
Expected results
pop until "thePath"
Actual results
the pop() is not working properly, so stuck in this while loop.
this was working in Go_Router 13.2.5, but not after v14
Code sample
Code sample
```dart extension GoRouterExt on GoRouter { String get _currentRoute => routerDelegate.currentConfiguration.matches.last.matchedLocation; void popToIndex(int index) { int currentIndex = routerDelegate.currentConfiguration.matches.length - 1; while (routerDelegate.currentConfiguration.matches.length > index) { if (!canPop() || currentIndex == index) { return; } pop(); currentIndex--; } } void popUntilPath(String ancestorPath) { while (_currentRoute != ancestorPath) { if (!canPop()) { return; } pop(); } } } ```Screenshots or Video
Screenshots / Video demonstration
[Upload media here]Logs
Logs
```console [Paste your logs here] ```Flutter Doctor output
Doctor output
```console [✓] Flutter (Channel stable, 3.22.0, on macOS 14.5 23F79 darwin-arm64, locale zh-Hant-TW) • Flutter version 3.22.0 on channel stable at /Users/shaynechang/development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 5dcb86f68f (4 months ago), 2024-05-09 07:39:20 -0500 • Engine revision f6344b75dc • Dart version 3.4.0 • DevTools version 2.34.3 [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) • Android SDK at /Users/shaynechang/Library/Android/sdk • Platform android-35, build-tools 35.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.4) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15F31d • CocoaPods version 1.15.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2024.1) • 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 17.0.10+0-17.0.10b1087.21-11609105) [✓] VS Code (version 1.92.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.94.0 [✓] Connected device (5 available) • sdk gphone16k arm64 (mobile) • emulator-5554 • android-arm64 • Android 15 (API 35) (emulator) • iPhone 15 (mobile) • C26EED6F-3C29-4D42-81CD-4535632B3A69 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 14.5 23F79 darwin-arm64 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.5 23F79 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.120 [✓] Network resources • All expected network resources are available. • No issues found! ```