run<R, P> method

  1. @override
Future<R> run<R, P>(
  1. FutureOr<R> function(
    1. P argument
  2. P argument,
  3. {Duration timeout,
  4. dynamic onTimeout(

    Execute function(argument) in the isolate and return the result.

    Sends function and argument to the isolate, runs the call, and returns the result, whether it returned a value or threw. If the call returns a Future, the final result of that future will be returned.

    This works similar to the arguments to Isolate.spawn, except that it runs in the existing isolate and the return value is returned to the caller.


    IsolateRunner iso = await IsolateRunner.spawn();
    try {
      return await, argument);
    } finally {
      await iso.close();


    Future<R> run<R, P>(FutureOr<R> Function(P argument) function, P argument,
        {Duration timeout, Function() onTimeout}) {
      return singleResultFuture<R>((SendPort port) {
        _commandPort.send(list4(_run, function, argument, port));
      }, timeout: timeout, onTimeout: onTimeout);