I am using a ShellRoute within my GoRouter with those arguments:
final GoRouter _vamosRouter = GoRouter(
debugLogDiagnostics: true,
initialLocation: EventsPage.route,
errorBuilder: (_, __) => const ErrorPage(),
routes: [
GoRoute(
path: LoginPage.route,
builder: (_, __) => const LoginPage(),
// redirect: (context, state) => context.read<UserViewModel>().isSignedIn ? EventsPage.route : null, // ändert nix
),
ShellRoute(
navigatorKey: _rootNavigatorKey,
builder: (_, __, child) => RootPage(widget: child),
routes: <RouteBase>[
GoRoute(path: ProfilePage.route, builder: (_, __) => const ProfilePage()),
GoRoute(path: OrganizationPage.route, builder: (_, __) => const OrganizationPage()),
GoRoute(path: EventsPage.route, builder: (_, __) => const EventsPage()),
],
),
],
redirect: (BuildContext context, _) => context.read<UserViewModel>().isSignedIn ? null : LoginPage.route,
);
My Root Page looks like this:
class RootPage extends StatelessWidget {
const RootPage({required this.widget});
final Widget widget;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Row(children: [const Sidebar(), Expanded(child: widget)]),
);
}
}
So the basic layout is: a sidebar on the left side, and the main widget on the right site.
Problem: when switching between pages (or the main widget), the whole (RootPage) screen is built up again. How can I switch between pages in the ShellRoute with just the widget on the right site being reloaded?