removeListener method
Remove a previously registered closure from the list of closures that the object notifies.
Implementation
@override
void removeListener(VoidCallback listener) {
for (var i = 0; i < _count; i++) {
final listenerAtIndex = _listeners[i];
final target = listenerAtIndex?.target;
// Remove the matching listener as well as weak references that no longer
// point to listeners, same as _garbageCollect().
if (target == listener || (target == null && listenerAtIndex != null)) {
if (_notificationCallStackDepth > 0) {
_listeners[i] = null;
_reentrantlyRemovedListeners++;
} else {
_removeAt(i);
}
break;
}
}
}