toStream method
Converts the table content to a stream of formatted strings, one for each row.
The produced strings are not terminated with a newline.
If this table already has rows, they will be included first in the stream and the column widths will be based on them. Subsequent rows might break the alignment if they have wider content.
Implementation
Stream<String> toStream(
final Stream<Iterable<String>>? rowStream, {
final int? limit,
}) async* {
final columnWidths = _getColumnWidths();
if (_columnHeaders.isNotEmpty) {
final headerLines = _formatHeader(columnWidths);
for (final line in headerLines) {
yield line;
}
}
int count = 0;
for (final row in _rows) {
yield _formatLine(columnWidths, row);
if (limit != null && ++count >= limit) return;
}
await for (final row in rowStream ?? Stream.empty()) {
yield _formatLine(columnWidths, row);
if (limit != null && ++count >= limit) return;
}
}