whenResolved<R> method

Future<R> whenResolved<R>(
  1. FutureOr<R> onResolve(
    1. V? value,
    2. Object? error,
    3. StackTrace? stackTrace
    )
)

Invokes a callback when this value resolves, either successfully or with an error, and maps the outcome to a new result.

The onResolve callback is always executed:

  • On success, it receives the resolved value and null error/stackTrace
  • On failure, it receives null value along with the error and stackTrace

Errors are not automatically rethrown. The onResolve callback determines how failures are handled by choosing to return a value, throw a new error, or rethrow the received error.

This method delegates to resolveAsync and then applies Future.whenResolved on the resulting Future.

Implementation

Future<R> whenResolved<R>(
        FutureOr<R> Function(V? value, Object? error, StackTrace? stackTrace)
            onResolve) =>
    resolveAsync().whenResolved(onResolve);