waitTryOr<T> function

Future<T?> waitTryOr<T>(
  1. T? defaultValue,
  2. Future<T?> closure()
)

Returns the result of the given closure, or default if an Exception was raised.

Implementation

Future<T?> waitTryOr<T>(T? defaultValue, Future<T?> Function() closure) async {
  try {
    return await closure();
  } on Exception {
    return defaultValue;
  }
}