androidiosflutterdartflutter-go-router

GoRouter passing wrong arguments to the route when I press on `Select Widget` in flutter inspector


I have this route with two nested routes:

          GoRoute(
            parentNavigatorKey: _homePageShellNavigatorKey,
            name: MenuScreen.routeName,
            path: '/menu_screen',
            pageBuilder: (_, state) {
              assert(
                state.extra is MenuScreenArgs || state.extra == null,
                'extra of menu_screen route should be null or have a type of MenuScreenArgs,'
                ' but instead got ${state.extra.runtimeType}',
              );
              return MaterialPage(
                child: MenuScreen(
                  args: state.extra as MenuScreenArgs?,
                ),
              );
            },
            routes: [
              GoRoute(
                parentNavigatorKey: _rootNavigatorKey,
                name: CoffeeDetailsScreen.routeName,
                path: 'coffee_details_screen',
                pageBuilder: (_, state) {
                  assert(
                    state.extra != null &&
                        state.extra is CoffeeDetailsScreenArgs,
                    'extra of coffee_details_screen route should have a type of'
                    ' CoffeeDetailsScreenArgs,'
                    ' but instead got ${state.extra.runtimeType}',
                  );
                  return MaterialPage(
                    child: CoffeeDetailsScreen(
                      args: state.extra as CoffeeDetailsScreenArgs,
                    ),
                  );
                },
              ),
              GoRoute(
               // ... another nested route
              ),
            ],
          ),
                CoffeeDetailsScreen.routeName,
                extra: CoffeeDetailsScreenArgs(productId: product.id),
              );
  assert(
                state.extra is MenuScreenArgs || state.extra == null,
                'extra of menu_screen route should be null or have a type of MenuScreenArgs,'
                ' but instead got ${state.extra.runtimeType}',
              );

Why is this happening, is it a bug or something wrong in my usage of the router?


Solution

  • Turned out to be a bug in the library itself. So it will be resolved once the maintainer fixes it in the package. https://github.com/flutter/flutter/issues/125900