Iam new to this architecture, I have a doubt regarding the bindings in getX
I have two controllers cartController and splashController I need this cartController to remain its state as for the entire lifecycle of app splashController only for the splashScreen
But the splash controller only works when I bind it with other controllers in initial binding in GetMaterialApp
GetMaterialApp(
home: const SplashScreen(),
initialBinding: RootBinding(),
getPages: [
GetPage(
name: SplashScreen.routeName,
page: () => const SplashScreen(),
),
GetPage(
name: HomeScreen.routeName,
page: () => const HomeScreen(),
children: [
GetPage(
name: CategoryScreen.routeName,
page: () => const CategoryScreen(),
),
GetPage(
name: AboutScreen.routeName,
page: () => const AboutScreen(),
),
GetPage(
name: CartScreen.routeName,
page: () => const CartScreen(),
),
]),
],
);
Root binding is
class RootBinding implements Bindings {
@override
void dependencies() {
Get.put<SplashController>(SplashController());
Get.put<HomeController>(HomeController());
Get.put<CategoryController>(CategoryController());
Get.put<AboutController>(AboutController());
}
}
It also doesn't work when i change it to Get.lazyPut()
I dont know if this is the best practise the above code works but when i remove a controller from initial binding to a page it doesnt work like below
GetPage(
name: SplashScreen.routeName,
page: () => const SplashScreen(),
binding: SplashBinding()
),
link to source code https://github.com/shabhi1997/GetXBaseProject/tree/master