spawn method

Creates and spawns an isolate that shares the same code as the current isolate.

Future<Isolate> spawn(
void entryPoint(message),
message,
{bool paused: false}
)

Creates and spawns an isolate that shares the same code as the current isolate.

The argument entryPoint specifies the entry point of the spawned isolate. It must be a top-level function or a static method that takes one argument - that is, one-parameter functions that can be compile-time constant function values. It is not allowed to pass the value of function expressions or an instance method extracted from an object.

The entry-point function is invoked with the initial message. Usually the initial message contains a SendPort so that the spawner and spawnee can communicate with each other.

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). This allows setting up error or exit listeners on the isolate before it starts running. To resume the isolate, call isolate.resume(isolate.pauseCapability).

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