when<R> method

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

    Performs an action based on the state of the AsyncValue.

    All cases are required, which allows returning a non-nullable value.


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