dolumnify function

String dolumnify (
  1. List<List<Object>> data,
  2. {String columnSplitter}
)

toString() will called on every object passed in

Implementation

String dolumnify(List<List<Object>> data, {String columnSplitter}) {
  final columnLengths = columnMaxLengths(data);
  final columnSep = columnSplitter ?? '  ';
  final lines = <String>[];
  for (final row in data) {
    final paddedItems =
        row.mapIndex((f, i) => f.toString().padRight(columnLengths[i]));

    lines.add(paddedItems.join(columnSep));
  }
  return lines.join('\n');
}