3

I am curious if creation of new objects removes all attached listeners. Here it is simple code:

class Notifier extends ChangeNotifier {}

final notifier = Notifier();

for (int i = 0; i < 2; i++) {
  // Should I remove listeners before creation new instance of `Notifier`?
  // Or new instantiaion assumes that all listeners attached to object will be removed?
  notifier?.removeListener(_listener);
  notifier = Notifier();
  notifier.addListener(_listener);
}

void _listener() {}
BambinoUA
  • 6,126
  • 5
  • 35
  • 51
  • This was answered at: https://stackoverflow.com/questions/61759948/removing-listerers-before-dispose-flutter – VFMiracle Oct 23 '22 at 11:16

0 Answers0