promiseToFuture<T> function

Future<T> promiseToFuture<T>(
  1. Object jsPromise
)

Converts a JavaScript Promise to a Dart Future.

// ignore: deprecated_member_use_from_same_package
import 'dart:js_util';

// ignore: deprecated_member_use_from_same_package
import 'package:js/js.dart';

@JS()
class Promise<T> {}

@JS()
external Promise<num> get threePromise; // Resolves to 3

void main() async {
  final Future<num> threeFuture = promiseToFuture(threePromise);

  final three = await threeFuture; // == 3
}

Implementation

external Future<T> promiseToFuture<T>(Object jsPromise);