I created a PostUpdaterWidget
extending StatelessWidget
which makes use of TextEditingControllers
for testing out implementation of Bloc P
This question seems to indicate that objects are not disposed when the StatelessWidget
gets destroyed, at least not immediately. In any case, when you are using a TextEditingController
(or maintaining any mutable state), then you should use a StatefulWidget
and keep the state in the State
class. The State
class has a dispose()
method that you can use (as you mentioned in your question).
Otherwise, if you use a StatelessWidget
, you lose your state every time the UI gets rebuilt. StatefulWidgets
keep their state across rebuilds because the state is in the State
class, not in the widget. See also this answer.