In general Getx controllers should be removed or disposed automatically. But if you wanna force to be removed there are a few ways, you can try.
1. Inside Build Method
If you want the controllers to be removed forcefully automatically, then you can inject the controller inside the build method of your class.
class MainScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
// ↓ instantiate/register here inside build ↓
final MyController controller = Get.put(MyController());
return Scaffold(
If you injected the dependencies inside the build() method, then it would be removed automatically.
2. Using Dispose Method
If you have stateful class, then you can use the dispose() method to remove the controller inside the stateful class.
@override
void dispose() {
Get.delete<Controller>();
super.dispose();
}
Here you delete the Controller forcefully. Make sure your use the correct controller name.
3. Machine problem
Based on our research we found, a lot of time on Windows machine, the controller does not get disposed or removed. But the same code works on Mac machine. So try to run the compile the code a different machine. You will see that it might work on Mac compilation.
Complete GetX App
GetX Advanced Operations