envelopeItemStream method
Stream binary data of Envelope
item.
Implementation
Future<List<int>> envelopeItemStream() async {
// Each item needs to be encoded as one unit.
// Otherwise the header already got yielded if the content throws
// an exception.
try {
final itemHeader = utf8JsonEncoder.convert(await header.toJson());
final newLine = utf8.encode('\n');
final data = await dataFactory();
return [...itemHeader, ...newLine, ...data];
} catch (e) {
return [];
}
}