close method

  1. @override
void close()
inherited

Closes the channel which means no more puts will be allowed. All pending takers will be invoked with End.

Implementation

@override
void close() {
  if (_isDebugMode) {
    _checkForbiddenStates();
  }

  if (_closed) {
    return;
  }

  _closed = true;

  if (onClose != null) onClose!();

  var arr = <TakeCallback<T>>[];
  arr.addAll(_takers);
  _takers.clear();

  arr.forEach((taker) => taker._onData(End as T));
}