promiseToFuture<T> function

Future<T> promiseToFuture <T>(
  1. Promise promise
)

Creates Dart Future which completes when promise is resolved or rejected.

See also:

Implementation

Future<T> promiseToFuture<T>(Promise promise) {
  var completer = new Completer<T>.sync();
  promise.then(allowInterop((value) {
    completer.complete(value);
  }), allowInterop((error) {
    completer.completeError(error);
  }));
  return completer.future;
}