Automatically CLOSE TO ROUTE gettng called deleting the dependencies injected.
the below code is used for navigating to next screen, and when I am clicking the back button provided by scaffold this is the output of log:
- [GETX] CLOSE TO ROUTE /add_family_history
- [GETX] "CatalogDiseaseRemoteService" deleted from memory
- [GETX] "CatalogDiseaseRepository" deleted from memory
- [GETX] "GetCatalogDisease" deleted from memory
- [GETX] "UpdateFamily" deleted from memory
- [GETX] "AddFamilyHistoryController" onDelete() called
- [GETX] "AddFamilyHistoryController" deleted from memory
and hence again going to the same page gives me
======== Exception caught by widgets library ======================================================= The following message was thrown building Builder(dirty): "GetCatalogDisease" not found. You need to call "Get.put(GetCatalogDisease())" or "Get.lazyPut(()=>GetCatalogDisease())"
the code used for navigation is this:
onButtonTap: () {
Get.toNamed(Routes.addFamilyHistory);
},
and the back button code of scaffold is this:
getAppBar1(String value,{List<Widget>? actions, bool? isBackIconEnable = true, bool? elevationDisable=false}) {
return AppBar(
backgroundColor: white,
elevation: elevationDisable!?0.0:0.5,
title: BaseText(
text: value,
textColor:Colors.black,
style: GoogleFonts.roboto(
fontSize: 14.0,
fontWeight: FontWeight.w400,
color: Colors.black),
textAlign: TextAlign.start,
),
centerTitle: false,
leading: isBackIconEnable!?IconButton(
icon: Image.asset(
getAssetsPNGImg('Arow'),
),
onPressed: () => Get.back()):const SizedBox(),
actions: actions,
);
}
Please help me avoid onDelete for dependencies.
where you inject the controller use the attribute permanenet to true to set the the controller saved in memory like this :
this error show because the controller is killed from memory for this reason Get,find will not found the controller use the method above or replace Get.find bu Get.put another time