middleSetCreator method

void middleSetCreator(
  1. StateStatus status,
  2. Object? result
)

Implementation

void middleSetCreator(StateStatus status, Object? result) {
  if (status == StateStatus.isWaiting) {
    isWaitingToInitialize = true;
    setToIsWaiting();
    return;
  }
  if (status == StateStatus.hasError) {
    assert(result is SnapError);
    if (isWaitingToInitialize) {
      setToHasError(
        (result as SnapError).error,
        stackTrace: result.stackTrace,
        refresher: result.refresher,
      );
    } else {
      _snapState = _snapState._copyToHasError(result as SnapError);
    }
    return;
  }
  if (isWaitingToInitialize) {
    setToHasData(result);
  } else {
    _snapState = _snapState.copyToIsIdle(data: result, infoMessage: '');
  }
}