previous method

void previous()

Moves focus to the previous focusable widget.

If a trap is active, only navigates within the trapped subtree.

Implementation

void previous() {
  final candidates = _getVisibleCandidates();
  if (candidates.isEmpty) return;

  final index = _focusedId == null ? 0 : candidates.indexOf(_focusedId!);
  final prevIndex = (index - 1 + candidates.length) % candidates.length;
  requestFocus(candidates[prevIndex]);
}