dolumnify function
toString() will called on every object passed in
Implementation
String dolumnify(
List<List<Object>> data, {
String columnSplitter = ' ',
bool headerIncluded = false,
String headerSeparator = ' ',
}) {
final columnLengths = columnMaxLengths(data);
final lines = <String>[];
for (var index = 0; index < data.length; index++) {
final paddedItems =
data[index].mapIndex((f, i) => f.toString().padRight(columnLengths[i]));
lines.add(paddedItems.join(columnSplitter));
if ((index == 0) && (headerIncluded == true)) {
final headerSeparatorLine = data[index].mapIndex((f, i) => headerSeparator
.padRight(columnLengths[i], headerSeparator)
.truncate(size: columnLengths[i]));
final headerSeparatorJoiner =
headerSeparator.padRight(columnSplitter.length, headerSeparator);
lines.add(headerSeparatorLine.join(headerSeparatorJoiner));
}
}
return lines.join('\n');
}