focusNextPage method

void focusNextPage()

Focus next page (jump by visibleOptionCount). Port of focus-next-page action from use-select-navigation.ts reducer.

Implementation

void focusNextPage() {
  final current = focusedValue.value;
  if (current == null) return;

  final item = optionMap.get(current);
  if (item == null) return;

  final targetIndex = math.min(
    optionMap.size - 1,
    item.index + visibleOptionCount,
  );

  // Walk to target index
  OptionMapItem<T>? target = optionMap.first;
  for (int i = 0; i < targetIndex && target != null; i++) {
    target = target.next;
  }
  if (target == null) return;

  focusedValue.value = target.value;
  _scrollToFocus();
  onFocus?.call(target.value);
}