safeCall<T> function

Future<T?> safeCall<T>(
  1. Future<T> future, [
  2. BuildContext? context
])

Implementation

Future<T?> safeCall<T>(Future<T> future, [BuildContext? context]) async {
  try {
    var result = await future;
    return result;
  } catch (error) {
    if (context != null) {
      showServerError(context, error: error);
    }
  }
  return null;
}