wrapAsync<T> function

Future<T?> wrapAsync<T>(
  1. String methodName,
  2. InternalLogger logger,
  3. Map<String, Object?>? attributes,
  4. WrappedCall<T> call,
)

Wraps a call to a platform channel that must return a value, with common error handling and telemetry. If you do not need to get a value back from your call, use wrap instead.

Implementation

Future<T?> wrapAsync<T>(String methodName, InternalLogger logger,
    Map<String, Object?>? attributes, WrappedCall<T> call) async {
  T? result;
  try {
    result = await call();
  } catch (e, st) {
    if (!_handleError(e, st, methodName, logger, attributes)) {
      rethrow;
    }
  }

  return result;
}