moveSelection method
Move the cursor by (dr, dc). When grow and the move runs off the last
row, a new blank row is appended (needs newRow).
Implementation
void moveSelection(int dr, int dc, {bool grow = false}) {
if (_editing) _editing = false;
var r = _sel.row + dr;
var c = _sel.col + dc;
if (c < 0) {
c = colCount - 1;
r -= 1;
}
if (c >= colCount) {
c = 0;
r += 1;
}
if (r >= rowCount && grow && newRow != null) {
_apply(List<T>.from(_rows)..add(newRow!()));
r = rowCount - 1;
}
r = r.clamp(0, rowCount - 1);
c = c.clamp(0, colCount - 1);
final next = CellRef(r, c);
if (next == _sel) {
notifyListeners();
return;
}
_sel = next;
notifyListeners();
}