Is it possible to ensure that a controller is disposed in Flutter?

Viewed 277

I have several controllers in my code (eg. TextEditingControllers, StreamControllers, ScrollControllers). Is there a way to get a warning/error if I ever forget to call the dispose() method on this variables?

I was hoping that there could be a lint for pedantic, but I couldn't find anything.

To clarify:

If initialize a controller

TextEditingController searchFieldController = TextEditingController();

And then forget to call

 @override
  void dispose() {
    searchFieldController.dispose();  // This line
    super.dispose();
 }

It should generate a warning

0 Answers
Related