updateCell method

void updateCell(
  1. int rowIndex,
  2. String columnName,
  3. dynamic newValue
)

Updates a cell at rowIndex in column columnName with newValue.

Implementation

void updateCell(int rowIndex, String columnName, dynamic newValue) {
  int colIndex = columns.indexOf(columnName);
  if (colIndex == -1)
    throw ArgumentError('Column "$columnName" does not exist.');
  if (rowIndex < 0 || rowIndex >= rows.length) {
    throw ArgumentError('Row index $rowIndex is out of range.');
  }
  rows[rowIndex][colIndex] = newValue;
  if (_schema != null) {
    final requiredType = _schema!.requiredColumns[columnName];
    if (requiredType != null &&
        newValue != null &&
        newValue.runtimeType != requiredType) {
      throw ArgumentError(
          'Column "$columnName" expects $requiredType but got ${newValue.runtimeType}.');
    }
  }
}