addSlice method
Adds the next chunk
to this
.
Adds the bytes defined by start
and end
-exclusive to this
.
If isLast
is true
closes this
.
Contrary to add
the given chunk
must not be held onto.
Once the method returns, it is safe to overwrite the data in it.
Implementation
@override
void addSlice(List<int> chunk, int start, int end, bool isLast) {
if (_closed) return;
RangeError.checkValidRange(start, end, chunk.length);
try {
_empty = false;
final bufferAndStart =
_PositionableBuffer.serializableByteData(chunk, start, end);
_filter.process(bufferAndStart.buffer, bufferAndStart.start,
end - (start - bufferAndStart.start));
while (true) {
final out = _filter.processed(flush: false);
if (out == null) break;
_sink.add(out);
}
} on Exception {
_closed = true;
_filter.close();
rethrow;
}
if (isLast) close();
}