moveBy method

bool moveBy(
  1. int delta
)

Moves selection by delta visible selectable rows.

Implementation

bool moveBy(int delta) {
  if (delta == 0) return false;
  final projected = _projectRows();
  if (projected.isEmpty) return false;
  final direction = delta.sign;
  var remaining = delta.abs();
  var next = _cursor < 0 ? (direction > 0 ? -1 : projected.length) : _cursor;
  var lastSelectable = _cursor;
  while (remaining > 0) {
    next += direction;
    while (next >= 0 &&
        next < projected.length &&
        !projected[next].item.selectable) {
      next += direction;
    }
    if (next < 0 || next >= projected.length) break;
    lastSelectable = next;
    remaining--;
  }
  if (lastSelectable < 0 ||
      lastSelectable >= projected.length ||
      lastSelectable == _cursor) {
    return false;
  }
  _cursor = lastSelectable;
  _ensureCursorVisible(projected.length);
  return true;
}