moveUp method

void moveUp()

Moves focus up by one row with wrapping.

Maintains the same column position when possible. Wraps from top row to bottom row.

Implementation

void moveUp() {
  if (_itemCount == 0) return;

  final col = _focusedIndex % _columns;
  var row = _focusedIndex ~/ _columns;
  final totalRows = rows;

  // Try each row above, wrapping around
  for (var i = 0; i < totalRows; i++) {
    row = (row - 1 + totalRows) % totalRows;
    final candidate = row * _columns + col;
    if (candidate < _itemCount) {
      _focusedIndex = candidate;
      return;
    }
  }
}