Skip to content

[go_router] Updating the GoRouter.routeConfig loses the router state #167344

Closed
flutter/packages
#12611

Description

@itsUndefined

Steps to reproduce

Reproducible in go_router 15.0.0

Start with the following config:

final config = RoutingConfig(routes: [
  StatefulShellRoute.indexedStack(
    restorationScopeId: 'navigationShell',
    builder: builder,
    branches: [
      StatefulShellBranch(
        restorationScopeId: 'home',
        routes: [
          GoRoute(path: '/home', builder: homeBuilder, routes: [
             GoRoute(path: '/a', builder: ABuilder)
          ])
        ]
      ),
    ],
  ),
]);

and add a button on ABuilder to update the routing config:

configNotifier.value = RoutingConfig // Same value as above
  1. From the home branch, navigate to /home/a using the push method ( imperative ). The issue doesn't happen with the go method.
  2. Click the reload button on the A widget
  3. Observe that the reload redirected the user back to /home

Expected results

Update route config, stay in the route: /home/a, and the history of the branch should be maintained

Actual results

Route config is updated but the history of the branch is lost, and the app redirected to /home

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

void main() {
  runApp(const App());
}

class App extends StatelessWidget {
  static final routingConfig = ValueNotifier<RoutingConfig>(createConfig());
  static final routerConfig = GoRouter.routingConfig(
    restorationScopeId: 'app-router',
    initialLocation: '/home',
    routingConfig: routingConfig,
  );

  const App({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      restorationScopeId: 'app',
      routerConfig: routerConfig,
    );
  }
}

Widget builder(
  BuildContext context,
  GoRouterState state,
  StatefulNavigationShell shell,
) {
  return Scaffold(
    bottomNavigationBar: NavigationBar(
      selectedIndex: shell.currentIndex,
      onDestinationSelected: (index) => shell.goBranch(index),
      destinations: [
        NavigationDestination(icon: const Icon(Icons.abc), label: 'Main'),
        NavigationDestination(icon: const Icon(Icons.abc), label: 'Ignore'),
      ],
    ),
    body: Center(child: shell),
  );
}

RoutingConfig createConfig() {
  return RoutingConfig(
    routes: [
      StatefulShellRoute.indexedStack(
        restorationScopeId: 'navigationShell',
        builder: builder,
        branches: [
          StatefulShellBranch(
            restorationScopeId: 'main',
            routes: [
              GoRoute(
                path: '/home',
                builder: createBuilder('main', canNavigate: true),
                routes: [
                  GoRoute(
                    path: '/a',
                    builder: createBuilder('a', allowReload: true),
                  ),
                ],
              ),
            ],
          ),
          StatefulShellBranch(
            restorationScopeId: 'ignore',
            routes: [
              GoRoute(
                path: '/ignore',
                builder: createBuilder('ignore', canNavigate: true),
              ),
            ],
          ),
        ],
      ),
    ],
  );
}

Widget Function(BuildContext, GoRouterState) createBuilder(
  String name, {
  bool allowReload = false,
  bool canNavigate = false,
}) {
  return (ctx, state) =>
      MyPage(allowReload: allowReload, canNavigate: canNavigate, name: name);
}

class MyPage extends StatelessWidget {
  final bool allowReload;
  final bool canNavigate;
  final String name;

  const MyPage({
    super.key,
    required this.allowReload,
    required this.canNavigate,
    required this.name,
  });

  @override
  Widget build(BuildContext context) {
    return Material(
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            if (allowReload)
              ElevatedButton(
                onPressed: () {
                  App.routingConfig.value = createConfig();
                },
                child: Text("Press me to reload config"),
              ),
            if (canNavigate)
              ElevatedButton(
                onPressed: () {
                  GoRouter.of(context).push('/home/a');
                },
                child: Text("Press me to navigate to nested route"),
              ),
            Text(name),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.29.1, on Microsoft Windows [Version 10.0.26100.3775], locale el-GR) [381ms]
    • Flutter version 3.29.1 on channel stable at C:\Users\itsUndefined\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 09de023485 (7 weeks ago), 2025-02-28 13:44:05 -0800
    • Engine revision 871f65ac1b
    • Dart version 3.7.0
    • DevTools version 2.42.2

[√] Windows Version (11 Pro 64-bit, 24H2, 2009) [1.989ms]

[√] Android toolchain - develop for Android devices (Android SDK version 35.0.1) [2,9s]
    • Android SDK at C:\Users\itsUndefined\AppData\Local\Android\Sdk
    • Platform android-35, build-tools 35.0.1
    • ANDROID_HOME = C:\Users\itsUndefined\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\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 21.0.5+-13047016-b750.29)
    • All Android licenses accepted.

[√] Chrome - develop for the web [120ms]
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.13.6) [118ms]
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.13.35931.197
    • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2024.2) [16ms]
    • Android Studio at C:\Program Files\Android\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 21.0.5+-13047016-b750.29)

[√] VS Code (version 1.99.2) [14ms]
    • VS Code at C:\Users\itsUndefined\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.108.0

[√] Connected device (4 available) [268ms]
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 15 (API 35) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.26100.3775]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 135.0.7049.85
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 135.0.3179.73

[√] Network resources [341ms]
    • All expected network resources are available.

• No issues found!

Activity

  1. maheshj01 commented on Apr 18, 2025

    @maheshj01
    Member

    Hey @itsUndefined,

    • I ran the below code sample
    • navigated to /home/a
    • reload

    and the page stays on /home/a

    Screen.Recording.2025-04-17.at.22.17.39.mov
    code sample
    import 'package:flutter/material.dart';
    import 'package:go_router/go_router.dart';
    
    void main() {
      runApp(const App());
    }
    
    class App extends StatelessWidget {
      static final routingConfig = ValueNotifier<RoutingConfig>(createConfig());
      static final routerConfig = GoRouter.routingConfig(
        restorationScopeId: 'app-router',
        initialLocation: '/home',
        routingConfig: routingConfig,
      );
    
      const App({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp.router(
          restorationScopeId: 'app',
          routerConfig: routerConfig,
        );
      }
    }
    
    Widget builder(
      BuildContext context,
      GoRouterState state,
      StatefulNavigationShell shell,
    ) {
      return Scaffold(
        bottomNavigationBar: NavigationBar(
          selectedIndex: shell.currentIndex,
          onDestinationSelected: (index) => shell.goBranch(index),
          destinations: [
            NavigationDestination(icon: const Icon(Icons.abc), label: 'Main'),
            NavigationDestination(icon: const Icon(Icons.abc), label: 'Ignore'),
          ],
        ),
        body: Center(child: shell),
      );
    }
    
    RoutingConfig createConfig() {
      return RoutingConfig(
        routes: [
          StatefulShellRoute.indexedStack(
            restorationScopeId: 'navigationShell',
            builder: builder,
            branches: [
              StatefulShellBranch(
                restorationScopeId: 'main',
                routes: [
                  GoRoute(
                    path: '/home',
                    builder: createBuilder('main', canNavigate: true),
                    routes: [
                      GoRoute(
                        path: '/a',
                        builder: createBuilder('a', allowReload: true),
                      ),
                    ],
                  ),
                ],
              ),
              StatefulShellBranch(
                restorationScopeId: 'ignore',
                routes: [
                  GoRoute(
                    path: '/ignore',
                    builder: createBuilder('ignore', canNavigate: true),
                  ),
                ],
              ),
            ],
          ),
        ],
      );
    }
    
    Widget Function(BuildContext, GoRouterState) createBuilder(
      String name, {
      bool allowReload = false,
      bool canNavigate = false,
    }) {
      return (ctx, state) =>
          MyPage(allowReload: allowReload, canNavigate: canNavigate, name: name);
    }
    
    final config = RoutingConfig(
      routes: [
        StatefulShellRoute.indexedStack(
          restorationScopeId: 'navigationShell',
          builder: builder,
          branches: [
            StatefulShellBranch(
              restorationScopeId: 'home',
              routes: [
                GoRoute(
                  path: '/home',
                  builder: createBuilder('main', canNavigate: true),
                  routes: [
                    GoRoute(
                      path: '/a',
                      builder: createBuilder('a', allowReload: true),
                    ),
                  ],
                ),
              ],
            ),
          ],
        ),
      ],
    );
    
    class MyPage extends StatelessWidget {
      final bool allowReload;
      final bool canNavigate;
      final String name;
    
      const MyPage({
        super.key,
        required this.allowReload,
        required this.canNavigate,
        required this.name,
      });
    
      @override
      Widget build(BuildContext context) {
        return Material(
          child: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                if (allowReload)
                  ElevatedButton(
                    onPressed: () {
                      App.routingConfig.value = config;
                    },
                    child: Text("Press me to reload config"),
                  ),
                if (canNavigate)
                  ElevatedButton(
                    onPressed: () {
                      GoRouter.of(context).push('/home/a');
                    },
                    child: Text("Press me to navigate to nested route"),
                  ),
                Text(name),
              ],
            ),
          ),
        );
      }
    }
    
    flutter doctor -v

    stable

    [!] Flutter (Channel stable, 3.29.3, on macOS 15.4 24E248 darwin-arm64, locale en-US) [591ms]
        • Flutter version 3.29.3 on channel stable at /Users/mahesh/Development/flutter
        ! Warning: `flutter` on your path resolves to /Users/mahesh/Development/flutter_master/bin/flutter, which is not inside your current
          Flutter SDK checkout at /Users/mahesh/Development/flutter. Consider adding /Users/mahesh/Development/flutter/bin to the front of
          your path.
        ! Warning: `dart` on your path resolves to /Users/mahesh/Development/flutter_master/bin/dart, which is not inside your current
          Flutter SDK checkout at /Users/mahesh/Development/flutter. Consider adding /Users/mahesh/Development/flutter/bin to the front of
          your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision ea121f8859 (5 days ago), 2025-04-11 19:10:07 +0000
        • Engine revision cf56914b32
        • 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.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [2.3s]
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-35, build-tools 35.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/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 21.0.5+-12932927-b750.29)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 16.3) [1,559ms]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 16E140
        • CocoaPods version 1.16.2
    
    [✓] Chrome - develop for the web [153ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2024.3) [152ms]
        • 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 21.0.5+-12932927-b750.29)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1) [150ms]
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.96.2) [22ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.102.0
    
    [✓] Connected device (4 available) [6.5s]
        • iPhone 15 Pro (mobile)          • 7BB5BB29-BA56-4EB1-B698-E6A1AAD138E4 • ios            •
          com.apple.CoreSimulator.SimRuntime.iOS-18-0 (simulator)
        • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 15.4 24E248 darwin-arm64
        • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 15.4 24E248 darwin-arm64
        • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 131.0.6778.265
    
    [✓] Network resources [351ms]
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Apr 18, 2025
  3. itsUndefined commented on Apr 18, 2025

    @itsUndefined
    Author

    Hi. This happens on Android platform. Sorry I forgot to mention.

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Apr 18, 2025
  5. maheshj01 commented on Apr 18, 2025

    @maheshj01
    Member

    Hey @itsUndefined I am unable to reproduce it on my end used the code sample here #167344 (comment)

    Screen.Recording.2025-04-18.at.15.05.06.mov

    Is this happening on a specific browser or device?

  6. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Apr 18, 2025
  7. itsUndefined commented on Apr 18, 2025

    @itsUndefined
    Author

    I am not creating a website. I am creating an android app. This issue doesn't happen in a browser but in an app.

  8. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Apr 18, 2025
  9. maheshj01 commented on Apr 18, 2025

    @maheshj01
    Member

    I see sorry about that and Thanks for the clarification.

    Reproducible on stable and the master channel updating the GoRouter.routeConfig loses the router state

    Screen.Recording.2025-04-18.at.16.21.38.mov
    flutter doctor -v

    master

    [✓] Flutter (Channel master, 3.32.0-1.0.pre.90, on macOS 15.4 24E248 darwin-arm64, locale en-US) [9.7s]
        • Flutter version 3.32.0-1.0.pre.90 on channel master at /Users/mahesh/Development/flutter_master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 29810cd6d1 (31 hours ago), 2025-04-16 00:07:50 +0530
        • Engine revision 29810cd6d1
        • Dart version 3.8.0 (build 3.8.0-265.0.dev)
        • DevTools version 2.45.0-dev.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [1,993ms]
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-35, build-tools 35.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/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 21.0.5+-12932927-b750.29)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 16.3) [1,369ms]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 16E140
        • CocoaPods version 1.16.2
    
    [✓] Chrome - develop for the web [131ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2024.3) [130ms]
        • 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 21.0.5+-12932927-b750.29)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1) [128ms]
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.96.2) [18ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.102.0
    
    [✓] Connected device (3 available) [6.3s]
        • iPhone 15 Pro (mobile) • 7BB5BB29-BA56-4EB1-B698-E6A1AAD138E4 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-0
          (simulator)
        • macOS (desktop)        • macos                                • darwin-arm64   • macOS 15.4 24E248 darwin-arm64
        • Chrome (web)           • chrome                               • web-javascript • Google Chrome 131.0.6778.265
    
    [✓] Network resources [395ms]
        • All expected network resources are available.
    
    • No issues found!

    stable

    [!] Flutter (Channel stable, 3.29.3, on macOS 15.4 24E248 darwin-arm64, locale en-US) [591ms]
        • Flutter version 3.29.3 on channel stable at /Users/mahesh/Development/flutter
        ! Warning: `flutter` on your path resolves to /Users/mahesh/Development/flutter_master/bin/flutter, which is not inside your current
          Flutter SDK checkout at /Users/mahesh/Development/flutter. Consider adding /Users/mahesh/Development/flutter/bin to the front of
          your path.
        ! Warning: `dart` on your path resolves to /Users/mahesh/Development/flutter_master/bin/dart, which is not inside your current
          Flutter SDK checkout at /Users/mahesh/Development/flutter. Consider adding /Users/mahesh/Development/flutter/bin to the front of
          your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision ea121f8859 (5 days ago), 2025-04-11 19:10:07 +0000
        • Engine revision cf56914b32
        • 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.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [2.3s]
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-35, build-tools 35.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/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 21.0.5+-12932927-b750.29)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 16.3) [1,559ms]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 16E140
        • CocoaPods version 1.16.2
    
    [✓] Chrome - develop for the web [153ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2024.3) [152ms]
        • 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 21.0.5+-12932927-b750.29)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1) [150ms]
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.96.2) [22ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.102.0
    
    [✓] Connected device (4 available) [6.5s]
        • iPhone 15 Pro (mobile)          • 7BB5BB29-BA56-4EB1-B698-E6A1AAD138E4 • ios            •
          com.apple.CoreSimulator.SimRuntime.iOS-18-0 (simulator)
        • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 15.4 24E248 darwin-arm64
        • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 15.4 24E248 darwin-arm64
        • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 131.0.6778.265
    
    [✓] Network resources [351ms]
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
  10. added
    packageflutter/packages repository. See also p: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Apr 18, 2025
  11. 7 remaining items

  12. georgiosd commented on May 29, 2025

    @georgiosd

    @maheshj01 don’t mean to be annoying but this is blocking for us. Any idea roughly the ETA?

  13. itsUndefined commented on Jun 2, 2025

    @itsUndefined
    Author

    @chunhtai I managed to identify the root cause of the issue. It's in the method RouteConfiguration.reparse. This method only handles ImperativeRouteMatches in the root navigator. It doesn't handle ImperativeRouteMatches inside ShellRouteMatches. I confirmed that in my example, the code below fixes the issue but it's not production ready. I think ShellRoutes can be nested infinitely deep so we need a recursive solution?

    Here is what I changed locally to fix the issue:

     /// Reparse the input RouteMatchList
      RouteMatchList reparse(RouteMatchList matchList) {
        RouteMatchList result = findMatch(matchList.uri, extra: matchList.extra);
    
        for (final ImperativeRouteMatch imperativeMatch
            in matchList.matches.whereType<ImperativeRouteMatch>()) {
          final ImperativeRouteMatch match = ImperativeRouteMatch(
              pageKey: imperativeMatch.pageKey,
              matches: reparse(imperativeMatch.matches),
              completer: imperativeMatch.completer);
          result = result.push(match);
        }
        
        /* SOLUTION STARTS HERE */
        for (final match in matchList.matches.whereType<ShellRouteMatch>()) {
          final resultMatch = result.matches
              .whereType<ShellRouteMatch>()
              .firstWhere( // Danger, if there is no navigatorKey set on the StatefulShellBranch, this will not work
                  (resultMatch) => resultMatch.navigatorKey == match.navigatorKey);
    
          final index = result.matches.indexOf(resultMatch);
          result.matches.removeAt(index);
          result.matches.insert(
              index,
              ShellRouteMatch(
                  pageKey: resultMatch.pageKey,
                  navigatorKey: resultMatch.navigatorKey,
                  matchedLocation: resultMatch.matchedLocation,
                  route: resultMatch.route,
                  matches: match.matches));
        }
        /* SOLUTION ENDS HERE */
    
        return result;
      }

    I am tagging you since I saw that you are the original author of this method.

  14. added a commit that references this issue on Sep 22, 2026
    c4ee37c
  15. added a commit that references this issue on Sep 24, 2026
    60a5571
  16. github-actions commented on Oct 6, 2026

    @github-actions

    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 -v and a minimal reproduction of the issue.

  17. locked as resolved and limited conversation to collaborators on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.29Found to occur in 3.29found in release: 3.32Found to occur in 3.32has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions