completerForPromise<T> function
Creates a completer for the given JS promise.
Implementation
Completer<T> completerForPromise<T>(Promise promise) {
Completer<T> out = Completer();
// Create interopts for promise
promise.then(allowInterop((value) {
out.complete(value);
}), allowInterop(([value]) {
out.completeError(value, StackTrace.current);
}));
return out;
}