cancelListeners method
Cancel all listeners added.
It is fine to call this method and then add additional listeners.
If excludeIds
is non-empty, any listeners that have an associated id
from _listenersById
will not be cancelled.
Implementation
void cancelListeners({List<String> excludeIds = const <String>[]}) {
assert(_listenables.length == _listeners.length);
final skipCancelIndices = <int>[];
for (int i = 0; i < _listenables.length; ++i) {
final listener = _listeners[i];
final listenerId = _listenerIdExpando[listener];
if (listenerId != null && excludeIds.contains(listenerId)) {
skipCancelIndices.add(i);
continue;
}
_listenables[i].removeListener(listener);
}
_listenables.removeAllExceptIndices(skipCancelIndices);
_listeners.removeAllExceptIndices(skipCancelIndices);
}