I'm using go_router 10.0.0 and it rebuilds every screen in the navigation stack every time I do push or pop. All screens are StatlessWidget and declare it as const constructors as I'm saving the state of each screen using State Management (using BLOC)
This behavior causes unnecessary screen build, unnecessary API calls and makes the screen lose its state How to solve This? My code
static GoRouter appRoutes = GoRouter(
navigatorKey: _navKey,
initialLocation: "/${_intialRout(_hiveManager, _configRoute)}",
observers: AppConstant.navigatorObservers(),
routerNeglect: true,
routes: [
///SignInMethodsScreen
GoRoute(
name: Routes.signInMethods,
path: "/${Routes.signInMethods}",
builder: (context, state) => const SignInMethodsScreen(),
),
///EnterEmailScreen
GoRoute(
name: Routes.enterEmailScreen,
path: "/${Routes.enterEmailScreen}",
builder: (context, state) => const EnterEmailScreen(),
),
///SignInScreen
GoRoute(
name: Routes.signinScreen,
path: "/${Routes.signinScreen}",
builder: (context, state) => const SignInScreen(),
),
///OtpScreen
GoRoute(
name: Routes.otpScreen,
path: "/${Routes.otpScreen}",
builder: (context, state) => const OtpScreen(),
),
///CreatePasswordScreen
GoRoute(
name: Routes.createPasswordScreen,
path: "/${Routes.createPasswordScreen}",
builder: (context, state) => const CreatePasswordScreen(),
),
///MainScreen
GoRoute(
name: Routes.mainScreen,
path: "/${Routes.mainScreen}",
builder: (context, state) => const MainScreen(),
),
],
);
navKey
? – Bartko