getValueSafely<T> function

T? getValueSafely<T>(
  1. T? getValueAction()
)

run getValueAction with try-catch return the result of getValueAction if no exception occurs, otherwise return null instead.

Implementation

T? getValueSafely<T>(T? Function() getValueAction) {
  try {
    return getValueAction.call();
  } catch(e, s) {
    return null;
  }
}