Dispose hook on widget rebuild

214 Views Asked by At

Do hooks dispose of themselves when a widget rebuilds? Is it possible to cause this behavior?

I'm using Riverpod for state management and I have a widget that creates a custom TextEditingController hook in the build method. When I update my widget's state (in Riverpod) the widget correctly rebuilds but it seems to retain the old TextEditingController hook. Is it possible to automatically dispose of and recreate it?

Thanks!

1

There are 1 best solutions below

5
Ruble On BEST ANSWER

The text controller will be disposed of as expected:

enter image description here

Therefore, nothing needs to be done.