run<I, O> static method

Future<O> run<I, O>(
  1. FutureOr<O> task(
    1. I data
    ), [
  2. I? data
])

Runs task in a separate isolate. data will be passed to the task.

Returns the result produced by the task.

Implementation

static Future<O> run<I, O>(FutureOr<O> Function(I data) task, [I? data]) {
  return Isolate.run<O>(() => task(data as I));
}