close method

void close()

Close this Notify and fail all current and future waiters.

All currently waiting tasks will fail with StateError, and any future calls to notified will return a failed future.

{@tool snippet example/notify_close.dart} {@end-tool}

Implementation

void close() {
  if (_closed) return;
  _closed = true;
  while (_waiters.isNotEmpty) {
    final c = _waiters.removeLast();
    if (!c.isCompleted) {
      c.completeError(StateError('Notify.disconnected'));
    }
  }
}