maybeWhen<R> method

R maybeWhen<R>({
  1. required R orElse(),
  2. R loading()?,
  3. R success(
    1. T data
    )?,
  4. R error(
    1. Object? error
    )?,
  5. R empty()?,
  6. 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(),
};