columnMaxLengths function

List<int> columnMaxLengths(
  1. List<List<Object>> data
)

Implementation

List<int> columnMaxLengths(List<List<Object>> data) {
  if (data.isEmpty) {
    return [];
  }
  final maxColumnLengths = List<int>.filled(data[0].length, 0);
  for (final row in data) {
    final columnCount = row.length;

    for (final column in _range(columnCount)) {
      final itemLength = row[column].toString().length;
      maxColumnLengths[column] = (itemLength > maxColumnLengths[column])
          ? itemLength
          : maxColumnLengths[column];
    }
  }
  return maxColumnLengths;
}