asyncCatchAll function

Future<bool> asyncCatchAll(
  1. Function function, {
  2. ErrorCallback? onError,
})

Runs the async function and ignore all the errors.

Runs function ErrorCallback onError when there is an error Returns true whether there is no error.

Implementation

Future<bool> asyncCatchAll(Function function, {ErrorCallback? onError}) async {
  try {
    await function();
    return true;
  } catch (error) {
    if (onError != null) {
      await onError(error);
    }
  }
  return false;
}