writeInputStream method Null safety
- InputStreamBase stream
override
Write an InputStream to the output stream.
Implementation
@override
void writeInputStream(InputStreamBase stream) {
if (stream is InputStream) {
final len = stream.length;
if (_bufferPosition + len >= _buffer.length) {
flush();
if (_bufferPosition + len < _buffer.length) {
for (int i = 0, j = _bufferPosition, k = stream.offset; i < len;
++i, ++j, ++k) {
_buffer[j] = stream.buffer[k];
}
_bufferPosition += len;
_length += len;
return;
}
}
if (_bufferPosition > 0) {
flush();
}
_fp.writeFromSync(stream.buffer, stream.offset, stream.offset + stream.length);
_length += stream.length;
} else {
var bytes = stream.toUint8List();
writeBytes(bytes);
}
}