orNull method

Future<T?> orNull()

Returns the result, or null if this future throws.

Example:

final user = await fetchUser().orNull();
if (user == null) showError();

Implementation

Future<T?> orNull() =>
    then<T?>((T value) => value).catchError((Object _) => null);