whenOrNull<R> method

R? whenOrNull<R>(
  1. {R data(
    1. T data
  2. R error(
    1. Object error,
    2. StackTrace? stackTrace
  3. R loading(

    Perform actions conditionally based on the state of the AsyncValue.

    Returns null if AsyncValue was in a state that was not handled.

    This is similar to maybeWhen where orElse returns null.


    R? whenOrNull<R>({
      R Function(T data)? data,
      R Function(Object error, StackTrace? stackTrace)? error,
      R Function()? loading,
    }) {
      return _map(
        data: (d) => data?.call(d.value),
        error: (e) => error?.call(e.error, e.stackTrace),
        loading: (l) => loading?.call(),