load method

  1. @protected
void load(
  1. int pageNo
)

Change the state to loading / loading more depends on the page to load.

This will be called when a search action (reload, search, next page) is performed.

DO NOT call this method directly, trigger it by performing a search action.

Implementation

@protected
void load(int pageNo) {
  if (_state is SearchStatusIdle<T>) {
    _state = const SearchStatusLoading();
  } else if (_state is SearchStatusDone<T>) {
    if (pageNo == 1) {
      _state = const SearchStatusLoading();
    } else {
      _state =
          SearchStatusLoadingMore((_state as SearchStatusDone<T>).result);
    }
  } else {
    throw StateError('Unexpected transition');
  }

  notifyListeners();
}