fetchNextBatch method
Fetch the next set of items from the same search
addToPage
is 0 when you call init since it shouldn't increase the page count
you are querying the first page
Implementation
Future<void> fetchNextBatch({int addToPage = 1}) async {
if (_timer?.isActive == true) {
// already processing another request
return;
}
_startTimer();
if (hasNoMoreItems) {
return;
} else if (state == PaginatedState.onGoingLoading(items)) {
return;
}
debugPrint('fetchNextBatch $query');
// use the same query to fetch the next items in search
// show ongoing loading
state = PaginatedState.onGoingLoading(items);
// increase the page number
page += addToPage;
_performSearch();
}