maybeMap<R extends Object?> method
R
maybeMap<R extends Object?>({
- required R orElse(),
- R initialState(
- InitialState<
T> initialState
- InitialState<
- R loadingState(
- LoadingState<
T> loadingState
- LoadingState<
- R succeedState(
- SucceedState<
T> succeedState
- SucceedState<
- R failedState(
- FailedState<
T> failedState
- FailedState<
Implementation
R maybeMap<R extends Object?>({
required R Function() orElse,
R Function(InitialState<T> initialState)? initialState,
R Function(LoadingState<T> loadingState)? loadingState,
R Function(SucceedState<T> succeedState)? succeedState,
R Function(FailedState<T> failedState)? failedState,
}) {
final FourStates<T> state = this;
return switch (state) {
InitialState<T>() => initialState == null ? orElse() : initialState(state),
LoadingState<T>() => loadingState == null ? orElse() : loadingState(state),
SucceedState<T>() => succeedState == null ? orElse() : succeedState(state),
FailedState<T>() => failedState == null ? orElse() : failedState(state),
};
}