runCaching<T> function
Run given action
in a try-catch block and calls onError
on exception.
Implementation
T? runCaching<T>(T Function() action,
{T? Function(dynamic error, StackTrace stacktrace)? onError}) {
try {
return action.call();
} catch (error, stacktrace) {
onError?.call(error, stacktrace);
return null;
}
}