addCol method

HDictBuilder addCol(
  1. String name, {
  2. HVal fill()?,
})

Add column and return builder for column metadata. Columns cannot be added after adding the first row.

Implementation

HDictBuilder addCol(String name, {HVal Function()? fill}) {
  if (!HDict.isTagName(name)) {
    throw ArgumentError("Invalid column name: $name");
  }

  BCol col = BCol(name);
  _cols.add(col);

  if (fill != null) {
    _rows.forEach((row) => row.add(fill()));
  } else {
    _rows.forEach((row) => row.add(null));
  }

  return col.meta;
}