create static method

Future create(
  1. Function fn
)

Create a Future from scratch.

await F4.create((resolve, reject)=>()=>resolve(1));

Implementation

static Future create(Function fn) {
  final completer = Completer();

  Function.apply(fn, [
    ([dynamic data]) => completer.complete(data),
    ([Object? e, StackTrace? s]) =>
        completer.completeError(e ?? RejectionError(), s)
  ]);

  return completer.future;
}