tabNext method

void tabNext({
  1. bool grow = true,
  2. bool backward = false,
})

Tab to the next cell in reading order. When the cursor is on the very last cell (last row, last column) and grow is true, a fresh blank row is appended first and the cursor lands on its first cell — so Tab keeps flowing data entry without ever reaching for the mouse. Pass backward for Shift+Tab.

Implementation

void tabNext({bool grow = true, bool backward = false}) {
  if (backward) {
    moveSelection(0, -1);
    return;
  }
  final atLastCell = _sel.row == rowCount - 1 && _sel.col == colCount - 1;
  if (atLastCell && grow) {
    final next = _clone()..add(blankRow());
    _sel = CellRef(next.length - 1, 0);
    _apply(next);
    return;
  }
  moveSelection(0, 1);
}