convertResultToStateAfterLoad method

Future<S> convertResultToStateAfterLoad(
  1. dynamic result
)

Implementation

Future<S> convertResultToStateAfterLoad(result) async {
  state.resultStatus = _getStatusFromResult(result) ?? state.resultStatus;

  if (result.isSuccess) {
    state.result = result.data;

    if (result is CacheResult) {
      state.result.numberOfCachedItems += state.result.items.count;
    } else {
      state.result.numberOfCachedItems = 0;
    }

    if (state is AbstractListFilterablePaginatedState) {
      state.result.hasMoreItems = state.result.items.count ==
          (state as AbstractListFilterablePaginatedState).searchModel.take;
    }
  }

  return state.copyWith();
}