class EventNotifier extends ValueNotifier<List<String>> {
// Omitted
@override
void dispose() {
streamSub.cancel();
super.dispose();
}
}
Dart does not have destructors.
Objects are automatically garbage collected when no longer referenced
In flutter we can do like for widget dispose:
@override
void dispose() {
// your dispose part
super.dispose();
}
dispose method used to release the memory allocated to variables when
state object is removed.
For example, if you are using a stream in your application then you
have to release memory allocated to the stream controller. Otherwise,
your app may get a warning from the PlayStore and AppStore about memory
leakage.