NullableFutureExtensions<T> extension
Extension on Future<T?>?
providing additional null-aware and error
handling operations.
This extension adds methods to nullable Future<T?>
objects, allowing for
more expressive handling of asynchronous operations that could result in
null or error states. It includes methods for providing default values,
handling errors gracefully, and more nuanced manipulations like executing
alternative futures or suppressing errors.
- on
-
- Future<
T?> ?
- Future<
Methods
-
catchErrorOrNull(
dynamic onError(Object), {bool test(Object)?}) → Future< T?> -
Available on Future<
Attempts to return the future's value; on error, executes an onError function and returns null.T?> ?, provided by the NullableFutureExtensions extension -
handleNull(
T defaultValue) → Future< T> -
Available on Future<
Returns the future's value if not null; otherwise, returns a default value.T?> ?, provided by the NullableFutureExtensions extension -
ignoreErrors(
) → Future< void> -
Available on Future<
Suppresses any errors that occur during the future's execution.T?> ?, provided by the NullableFutureExtensions extension -
onErrorOrNull(
void onError(dynamic error)) → Future< void> -
Available on Future<
Executes the providedT?> ?, provided by the NullableFutureExtensions extensiononError
function if the future completes with an error. -
onErrorReturn(
T value) → Future< T?> -
Available on Future<
Attempts to return the future's value; on error, returns a specified valueT?> ?, provided by the NullableFutureExtensions extensionvalue
is the value to be returned when an error occurs. -
onErrorReturnNull(
) → Future< T?> -
Available on Future<
Attempts to return the future's value; on error, returns null.T?> ?, provided by the NullableFutureExtensions extension -
onSuccess(
void onSuccess(T value)) → Future< void> -
Available on Future<
Executes the providedT?> ?, provided by the NullableFutureExtensions extensiononSuccess
function if the future completes successfully with a non-null value. -
orDefault(
T defaultValue) → Future< T> -
Available on Future<
Returns the future's value if not null; otherwise, returns a default valueT?> ?, provided by the NullableFutureExtensions extension -
orElse(
Future< T> alternative()) → Future<T> -
Available on Future<
Returns the future's value if not null; otherwise, executes an alternative future.T?> ?, provided by the NullableFutureExtensions extension -
orNull(
) → Future< T?> -
Available on Future<
Returns the future's value, or null if the future itself is null.T?> ?, provided by the NullableFutureExtensions extension -
thenOrNull<
R> (FutureOr< R?> onValue(T?)) → Future<R?> -
Available on Future<
Applies the providedT?> ?, provided by the NullableFutureExtensions extensiononValue
function to the future's value if it is not null. -
timeoutWithNull(
Duration duration) → Future< T?> -
Available on Future<
Returns null if the future does not complete within a specified duration.T?> ?, provided by the NullableFutureExtensions extension -
transform<
R> (R transform(T value)) → Future< R?> -
Available on Future<
Applies the providedT?> ?, provided by the NullableFutureExtensions extensiontransform
function to the future's value if it is not null. -
unwrap(
) → Future< T> ? -
Available on Future<
Unwraps the future, throwing an error if the future or its value is null.T?> ?, provided by the NullableFutureExtensions extension -
whenComplete(
dynamic action()) → Future< T?> -
Available on Future<
Executes a specified action when the future completes, regardless of the outcome.T?> ?, provided by the NullableFutureExtensions extension