removeListener method
- ImageStreamListener listener
Stops the specified listener
from receiving image stream events.
If listener
has been added multiple times, this removes the first
instance of the listener.
Once all listeners have been removed and all keepAlive handles have been disposed, this image stream is no longer usable.
Implementation
void removeListener(ImageStreamListener listener) {
_checkDisposed();
for (int i = 0; i < _listeners.length; i += 1) {
if (_listeners[i] == listener) {
_listeners.removeAt(i);
break;
}
}
if (_listeners.isEmpty) {
final List<VoidCallback> callbacks = _onLastListenerRemovedCallbacks.toList();
for (final VoidCallback callback in callbacks) {
callback();
}
_onLastListenerRemovedCallbacks.clear();
_maybeDispose();
}
}