Answers for "Flutter "Controller" onDelete() called [GETX] "Controller" deleted from memory"

0

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
Posted by: Guest on February-22-2022

Code answers related to "Flutter "Controller" onDelete() called [GETX] "Controller" deleted from memory"

Browse Popular Code Answers by Language