callMethodAwaitPromise method

Future callMethodAwaitPromise(
  1. String method, [
  2. List? arguments
])

Implementation

Future<dynamic> callMethodAwaitPromise(String method,
    [List<dynamic>? arguments]) {
  JSObject promiseObject = callMethod(method, arguments);
  final completer = Completer();
  (promiseObject.callMethod("then", [
    (result) {
      completer.complete(result);
    }
  ]) as JSObject)
      .callMethod("catch", [
    (error) {
      completer.completeError(error);
    }
  ]);
  return completer.future;
}