addSlice method

  1. @override
void addSlice(
  1. String str,
  2. int start,
  3. int end,
  4. bool isLast,
)
override

Adds the next chunk to this.

Adds the substring defined by start and end-exclusive to this.

If isLast is true closes this.

Implementation

@override
void addSlice(String str, int start, int end, bool isLast) {
  if (_closed) return;
  end = RangeError.checkValidRange(start, end, str.length);
  if (isLast) _closed = true;
  if (start < end) {
    _process(str, start, end, isLast);
  } else if (isLast && _carry.isNotEmpty) {
    final carry = _carry;
    _carry = '';
    _process(carry, 0, carry.length, true);
  }
  if (isLast) {
    onClose?.call(position: _offset, buffer: '');
    sink.close();
  }
}