safeUpdate<T> static method

T? safeUpdate<T>(
  1. T update(), {
  2. T? fallback,
})

Execute a function safely, returning fallback on error

Implementation

static T? safeUpdate<T>(T Function() update, {T? fallback}) {
  try {
    return update();
  } catch (e, stackTrace) {
    Logger.error('State update error', e);
    Logger.debug('Stack trace', stackTrace);
    return fallback;
  }
}