invokeSafely<T> static method

Future<T?> invokeSafely<T>(
  1. FutureOr<T> action()
)

Invokes the given function safely. By safely, we mean it will catch all exceptions and ignore them.

Implementation

static Future<T?> invokeSafely<T>(FutureOr<T> action()) async {
  try {
    return await action();
  } catch (_) {
  }
}