checkColumns method

void checkColumns()

Check that each column has the same amount of rows

Throws an ArgumentError, if a column has a different amount of rows.

Implementation

void checkColumns() {
  if (_columns.isEmpty) return;

  final rowLen = _columns.first.length;
  for (var i = 0; i < _columns.length; i++) {
    final c = _columns[i];
    final currentRowLen = c.length;

    if (currentRowLen != rowLen) {
      throw ArgumentError.value(
        currentRowLen,
        c.name,
        "Each column in the table `$name` must have the same amount of rows, "
        "which would be $rowLen, but this column has a different amount "
        "of rows",
      );
    }
  }
}