Flutter "Controller" onDelete() called [GETX] "Controller" deleted from memory
You need to bind all controller and the add in GetMaterialApp.
You facing this issue because of when you use back at that time it remove or delete controller like : [GETX] "LoginController" onDelete() called
For prevent this issue you need to create InitialBinding.
InitialBinding
class InitialBinding implements Bindings {
@override
void dependencies() {
Get.lazyPut(() => LoginController(LoginRepo()), fenix: true);
Get.lazyPut(() => HomeController(HomeRepo()), fenix: true);
}
}
In Main method :
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Get.put(AppController());
return GetMaterialApp(
title: StringConst.APP_NAME,
debugShowCheckedModeBanner: false,
defaultTransition: Transition.rightToLeft,
initialBinding: InitialBinding(),
theme: ThemeData(
primarySwatch: ColorConst.COLOR,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
initialRoute: RoutersConst.initialRoute,
getPages: routes(),
);
}
}
Thanks