processed method
Return a chunk of processed data.
When there is no more data available, processed will return null
.
Set flush
to false
for non-final calls to improve performance of
some filters
The last call to processed should have end
set to true
. This will
ensure the stream has an opportunity to be finalized with any trailing
data.
Implementation
List<int>? processed({bool flush = true, bool end = false}) {
if (!processing) return null;
if (!end && !hasMoreToProcess()) return null;
final builder = BytesBuilder(copy: false);
if (_outputBuffer.unreadCount > 0) {
final bufferedBytes = _outputBuffer.writtenBytes(reset: true);
builder.add(bufferedBytes);
} else {
if (_toProcess.isNotEmpty) _toProcess = _toProcess.drainTo(_inputBuffer);
_codeOrDecode();
final bufferedBytes = _outputBuffer.writtenBytes(reset: true);
builder.add(bufferedBytes);
if (flush == true) _flush(builder);
if (end == true) _finalize(builder);
}
// Return null if no bytes were added to the builder
if (builder.isEmpty) {
return null;
}
return builder.takeBytes();
}