mayBeMap<R extends Object?> method
R
mayBeMap<R extends Object?>({})
Implementation
R mayBeMap<R extends Object?>({
required R Function() orElse,
R Function()? initialState,
R Function(double? progress)? loadingState,
R Function(T successObject)? succeedState,
R Function(String? failureMessage, dynamic exception)? failedState,
}) {
final FourStates<T> state = this;
return switch (state) {
InitialState<T>() => initialState == null ? orElse() : initialState(),
LoadingState<T>() => loadingState == null ? orElse() : loadingState(state.progress),
SucceedState<T>() => succeedState == null ? orElse() : succeedState(state.successObject),
FailedState<T>() =>
failedState == null ? orElse() : failedState(state.failureMessage, state.exceptionObject),
};
}