focusPreviousSearchResult method

void focusPreviousSearchResult({
  1. bool loop = false,
})

Sets the focus on the previous search result.

Does nothing if there are no results or the first node is already focused.

If loop is true and the current focused search result is the first element of searchResults, the last element of searchResults is focused.

See also:

Implementation

void focusPreviousSearchResult({bool loop = false}) {
  if (searchResults.isEmpty) {
    return;
  }

  if (_focusedSearchResultIndex > 0) {
    _focusedSearchResultIndex -= 1;
    notifyListeners();
  } else if (loop) {
    _focusedSearchResultIndex = _searchResults.length - 1;
    notifyListeners();
  }
}