insertColumn method

void insertColumn({
  1. String header = '',
  2. TextAlignment alignment = TextAlignment.left,
  3. int width = 0,
  4. int? index,
})

Insert a new column into the table.

If a width is specified, this is used to wrap the table contents. If no width is specified, the column will be set to the maximum width of content in the cell.

An index may be specified with a value from 0..columns to insert the column in a specific location.

Implementation

void insertColumn(
    {String header = '',
    TextAlignment alignment = TextAlignment.left,
    int width = 0,
    int? index}) {
  final insertIndex = index ?? columns;
  _table[0].insert(insertIndex, header);
  _columnAlignments.insert(insertIndex, alignment);
  _columnWidths.insert(insertIndex, width);

  // Skip header and add empty cells
  for (var i = 1; i < _table.length; i++) {
    _table[i].insert(insertIndex, '');
  }

  assert(_tableIntegrity);
}