Call when the listener is no longer in use.
Do not use the object after calling dispose.
Subclasses must call this method in their overridden dispose, if any.
Implementation
@mustCallSuper
void dispose() {
assert(_debugAssertNotDisposed());
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
if (kFlutterMemoryAllocationsEnabled) {
FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
}
binding.removeObserver(this);
assert(() {
_debugDisposed = true;
return true;
}());
}