navigateToMatch method

void navigateToMatch({
  1. bool moveUp = false,
})

This method takes in a boolean parameter moveUp, if set to true, the match located above the current selected match is newly selected. Otherwise the match below the current selected match is newly selected.

Implementation

void navigateToMatch({bool moveUp = false}) {
  if (matchWrappers.value.isEmpty) return;

  if (moveUp) {
    selectedIndex = selectedIndex <= 0
        ? matchWrappers.value.length - 1
        : selectedIndex - 1;
  } else {
    selectedIndex = selectedIndex >= matchWrappers.value.length - 1
        ? 0
        : selectedIndex + 1;
  }

  _highlightCurrentMatch(queriedPattern);
}