takeStream method
Returns the output stream on the first call, or null afterwards.
Implementation
WASIPreview2OutputStream? takeStream() {
if (_stream != null || _finished) {
return null;
}
return _stream = WASIPreview2OutputStream(
onWrite: (chunk) {
if (_finished || _chunks.isClosed) {
return 'stream-closed';
}
_chunks.add(chunk);
_writtenLength += BigInt.from(chunk.length);
return null;
},
);
}