search method

void search({
  1. required Q? query,
})

Implementation

void search({required Q? query}) async {
  state = state.copyWith(type: PaginatedStateType.loading);
  _debounceCounter++;
  int tempDebounceCounter = _debounceCounter;

  // debounce search if this function is called within the given timeframe
  await Future.delayed(debounceDuration);

  if (_debounceCounter != tempDebounceCounter) {
    // there was another search requested, we will complete the other search and skip this one
    return;
  }

  // resetting the variables for this new search
  state = state.getInitialSearchState(query: query);
  _performSearch();
}