How do you use the Isolate.spawnUri method to control an isolate?


I’m looking through the documentation for Isolates and noticed that you can use the static method spawnUri to create an isolate from a file.

As seen here:

On that document it states that it returns a future of which returns a Isolate instance however there is no other methods.

Does anyone know how exactly you go about using this instance to send messages back and forth between the isolates?

Current Code:

 Isolate.spawnUri(Uri.parse(myLibraryFileName),[],"").then((Isolate iso) { 

      // Is there a way of getting the SendPort of the isolate? 
     //Or is there other ways of calling different functions in
     //code (and being able to send messages back to the main isolate)

Thank you.


The methods to control the isolate are not implemented yet. Eventually we want to add methods to kill, pause, or inspect the spawned isolates.

If you want the spawned isolate to send something back you have to send a SendPort in your initial message. See the examples that came with the BREAKING CHANGE announcement:!topic/misc/EVUMkZXFXtY

Answered By – Florian Loitsch

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *