can you run Isolate.spawn multiple times?


here is a simple code that I use to learn isolate, I spawn twice, but the second spawn does not show anything, any mistake here? Thanks

import 'dart:isolate';
Future<void> main() async {
  await Isolate.spawn(echo, 'Dart');
  await Isolate.spawn(echo, 'Flutter'); // why this 2nd spawn not showing up?

void echo(msg) {


Your program quits before the Isolate has done its job. You can confirm this if you add

await Future.delayed(Duration(seconds: 1));

somewhere towards the end of your program.

Setting up Isolates is often a bit challenging, with all the SendPort stuff etc.

Answered By – Eiko

Answer Checked By – David Goodson (FlutterFixes Volunteer)

Leave a Reply

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