handleNativeCall<T> method

Future<T> handleNativeCall<T>(
  1. Future future
)

Implementation

Future<T> handleNativeCall<T>(Future<dynamic> future) {
  final completer = Completer<T>();
  future
      .then((nativeResult) {
        final result = BlueConicNativeResult.fromNative(nativeResult);
        if (result.success) {
          completer.complete(result as T);
        } else {
          completer.completeError(Exception(result.error ?? 'Unknown error'));
        }
      })
      .catchError((error) {
        completer.completeError(error);
      });
  return completer.future;
}