add method

  1. @override
void add(
  1. String data
)
override

Adds data to the sink.

Must not be called after a call to close.

Implementation

@override
void add(String data) {
  if (_isClosed) {
    throw StateError('Chunked data sink already closed');
  }

  this.data = this.data.isNotEmpty ? '${this.data}$data' : data;
  final length = this.data.length;
  end = start + length;
  if (bufferLoad < length) {
    bufferLoad = length;
  }

  sleep = false;
  while (!sleep) {
    final h = handle;
    handle = null;
    if (h == null) {
      break;
    }

    h();
  }

  if (_cuttingPosition > start) {
    this.data = _cuttingPosition != end
        ? this.data.substring(_cuttingPosition - start)
        : '';
    start = _cuttingPosition;
  }
}