run<R> static method

Future<R> run<R>(
  1. FutureOr<R> computation(),
  2. CancellationToken? cancellationToken, {
  3. String? debugName,
})

A cancellable implementation of Dart's Isolate.run method.

Runs computation in a new isolate and returns the result. When cancelled, the isolate is killed.

When building for web, this uses CancellableFuture.from as a fallback due to isolates not being supported.

Implementation

static Future<R> run<R>(
  FutureOr<R> Function() computation,
  CancellationToken? cancellationToken, {
  String? debugName,
}) =>
    runImpl(computation, cancellationToken, debugName: debugName);