setCell method

void setCell(
  1. int x,
  2. int y,
  3. Cell? cell
)

Sets the cell at (x, y) and updates dirty tracking.

Implementation

void setCell(int x, int y, Cell? cell) {
  if (y < 0 || y >= lines.length) return;
  final current = cellAt(x, y);
  final next = cell ?? Cell.emptyCell();
  if (current == null || current != next) {
    final w = next.width > 0 ? next.width : 1;
    touchLine(x, y, w);
  }
  lines[y].set(x, cell);
}