0

On using context.push('/profile/check'); the builder function isn't called and hence the Text("Check") shows inside the AppScaffold.


late final GoRouter router = GoRouter(
    initialLocation: '/',
    refreshListenable: appService,
    navigatorKey: _rootNavigatorKey,
    routes: <RouteBase>[
      ShellRoute(
        navigatorKey: _rootShellNavigatorKey,
        builder: (BuildContext context, GoRouterState state, child) => AppScaffold(
          child: child,
        ),
        routes: [
          GoRoute(
            parentNavigatorKey: _rootShellNavigatorKey,
            path: '/',
            builder: (BuildContext context, GoRouterState state) {
              return HomeScreen();
            },
          ),
          GoRoute(
            parentNavigatorKey: _rootShellNavigatorKey,
            path: '/profile',
            builder: (BuildContext context, GoRouterState state) {
              return ProfilePageView();
            },
            routes: [
              ShellRoute(
                builder: (context, state, child) {
                  print('builder function not being called');
                  return Text("hello world");
                },
                routes: [
                  GoRoute(
                    path: 'check',
                    builder: (BuildContext context, GoRouterState state) {
                      return Center(
                        child: Text("Check"),
                      );
                    },
                  ),
                  GoRoute(
                    path: 'test',
                    builder: (BuildContext context, GoRouterState state) {
                      return Center(
                        child: Text("Test"),
                      );
                    },
                  ),
                ],
              ),
            ],
          ),
        ],
      ),
    ],
  );
Rohan
  • 57
  • 3
  • 10
  • Unfortunately it seems that it is a bug, I've found these issues that seems to be related. https://github.com/flutter/flutter/issues/111842 and https://github.com/flutter/flutter/issues/120665 – Acácio Veit Schneider Jun 02 '23 at 17:24

1 Answers1

0

Having the same issue use GoRouter.of(context).go('...'); and everything should work fine