Future<Isolate> spawnUri(
Uri uri,
List<String> args,
message,
{bool paused: false,
bool checked,
Uri packageRoot,
Map<String,Uri> packages,
bool errorsAreFatal,
SendPort onExit,
SendPort onError}
)

Creates and spawns an isolate that runs the code from the library with the specified URI.

The isolate starts executing the top-level main function of the library with the given URI.

The target main must be callable with zero, one or two arguments. Examples:

  • main()
  • main(args)
  • main(args, message)

When present, the parameter args is set to the provided args list. When present, the parameter message is set to the initial message.

If the paused parameter is set to true, the isolate will start up in a paused state, as if by an initial call of isolate.pause(isolate.pauseCapability). To resume the isolate, call isolate.resume(isolate.pauseCapability).

If the errorAreFatal, onExit and/or onError parameters are provided, the isolate will act as if, respectively, setErrorsFatal, addOnExitListener and addErrorListener were called with the corresponding parameter and was processed before the isolate starts running.

You can also call the setErrorsFatal, addOnExitListener and addErrorListener methods on the returned isolate, but unless the isolate was started as paused, it may already have terminated before those methods can complete.

If the checked parameter is set to true or false, the new isolate will run code in checked mode, respectively in production mode, if possible. If the parameter is omitted, the new isolate will inherit the value from the current isolate.

It may not always be possible to honor the checked parameter. If the isolate code was pre-compiled, it may not be possible to change the checked mode setting dynamically. In that case, the checked parameter is ignored.

WARNING: The checked parameter is not implemented on all platforms yet.

If either the packageRoot or the packages parameter is provided, it is used to find the location of package sources in the spawned isolate.

The packageRoot URI must be a "file" or "http"/"https" URI that specifies a directory. If it doesn't end in a slash, one will be added before using the URI, and any query or fragment parts are ignored. Package imports (like "package:foo/bar.dart") in the new isolate are resolved against this location, as by packageRoot.resolve("foo/bar.dart").

The packages map maps package names to URIs with the same requirements as packageRoot. Package imports (like "package:foo/bar/baz.dart") in the new isolate are resolved against the URI for that package (if any), as by `packages"foo".resolve("bar/baz.dart")

This resolution also applies to the main entry uri if that happens to be a package-URI.

If both packageRoot and packages are omitted, the new isolate uses the same package resolution as the current isolate. It's not allowed to provide both a packageRoot and a package parameter.

WARNING: The packageRoot and packages parameters are not implemented on all platforms yet.

Returns a future that will complete with an Isolate instance if the spawning succeeded. It will complete with an error otherwise.

Source

/**
 * Creates and spawns an isolate that runs the code from the library with
 * the specified URI.
 *
 * The isolate starts executing the top-level `main` function of the library
 * with the given URI.
 *
 * The target `main` must be callable with zero, one or two arguments.
 * Examples:
 *
 * * `main()`
 * * `main(args)`
 * * `main(args, message)`
 *
 * When present, the parameter `args` is set to the provided [args] list.
 * When present, the parameter `message` is set to the initial [message].
 *
 * If the [paused] parameter is set to `true`,
 * the isolate will start up in a paused state,
 * as if by an initial call of `isolate.pause(isolate.pauseCapability)`.
 * To resume the isolate, call `isolate.resume(isolate.pauseCapability)`.
 *
 * If the [errorAreFatal], [onExit] and/or [onError] parameters are provided,
 * the isolate will act as if, respectively, [setErrorsFatal],
 * [addOnExitListener] and [addErrorListener] were called with the
 * corresponding parameter and was processed before the isolate starts
 * running.
 *
 * You can also call the [setErrorsFatal], [addOnExitListener] and
 * [addErrorListener] methods on the returned isolate, but unless the
 * isolate was started as [paused], it may already have terminated
 * before those methods can complete.
 *
 * If the [checked] parameter is set to `true` or `false`,
 * the new isolate will run code in checked mode,
 * respectively in production mode, if possible.
 * If the parameter is omitted, the new isolate will inherit the
 * value from the current isolate.
 *
 * It may not always be possible to honor the `checked` parameter.
 * If the isolate code was pre-compiled, it may not be possible to change
 * the checked mode setting dynamically.
 * In that case, the `checked` parameter is ignored.
 *
 * WARNING: The [checked] parameter is not implemented on all platforms yet.
 *
 * If either the [packageRoot] or the [packages] parameter is provided,
 * it is used to find the location of package sources in the spawned isolate.
 *
 * The `packageRoot` URI must be a "file" or "http"/"https" URI that specifies
 * a directory. If it doesn't end in a slash, one will be added before
 * using the URI, and any query or fragment parts are ignored.
 * Package imports (like `"package:foo/bar.dart"`) in the new isolate are
 * resolved against this location, as by
 * `packageRoot.resolve("foo/bar.dart")`.
 *
 * The `packages` map maps package names to URIs with the same requirements
 * as `packageRoot`. Package imports (like `"package:foo/bar/baz.dart"`) in
 * the new isolate are resolved against the URI for that package (if any),
 * as by `packages["foo"].resolve("bar/baz.dart")
 *
 * This resolution also applies to the main entry [uri]
 * if that happens to be a package-URI.
 *
 * If both [packageRoot] and [packages] are omitted, the new isolate uses
 * the same package resolution as the current isolate.
 * It's not allowed to provide both a `packageRoot` and a `package` parameter.
 *
 * WARNING: The [packageRoot] and [packages] parameters are not implemented
 * on all platforms yet.
 *
 * Returns a future that will complete with an [Isolate] instance if the
 * spawning succeeded. It will complete with an error otherwise.
 */
external static Future<Isolate> spawnUri(
    Uri uri,
    List<String> args,
    var message,
    {bool paused: false,
     bool checked,
     Uri packageRoot,
     Map<String, Uri> packages,
     bool errorsAreFatal,
     SendPort onExit,
     SendPort onError});