maybeWhen<R> method
R
maybeWhen<R>({
- required R orElse(),
- R loading()?,
- R success(
- T data
- R error(
- Object? error
- R empty()?,
- R custom()?,
Implementation
R maybeWhen<R>({
required R Function() orElse,
R Function()? loading,
R Function(T data)? success,
R Function(Object? error)? error,
R Function()? empty,
R Function()? custom,
}) => switch (this) {
LoadingStatus() when loading != null => loading(),
SuccessStatus(:final data) when success != null => success(data),
ErrorStatus(error: final err) when error != null => error(err),
EmptyStatus() when empty != null => empty(),
CustomStatus() when custom != null => custom(),
_ => orElse(),
};