moveToPreviousItem method

bool moveToPreviousItem()

Moves focus to the previous item in the list. Returns true if focus was moved, false if at the beginning.

Implementation

bool moveToPreviousItem() {
  if (_itemCount == 0) return false;

  if (_focusedIndex > 0) {
    _focusedIndex--;
    notifyListeners();
    return true;
  } else if (_focusedIndex == -1 && _itemCount > 0) {
    // If no item is focused, focus the last item
    _focusedIndex = _itemCount - 1;
    notifyListeners();
    return true;
  }
  return false;
}