2

I'm using Flutter and need to do some parsing. To prevent said parsing from blocking the UI, I'm using an Isolate ; however spawning the Isolate seems to have a big time cost (~2s on my Samsung A5, with the 'compute' fonction). Which is a bit stupid, since the parsing takes less time then that... Since I don't want my users to have to wait for 2 seconds 'for free', I'd like to launch an Isolate when the app starts, and just give it the parsing to do when I need to do it.

What is the best way to accomplish this in Dart ? There's probably something better to do then a while(true) loop...

Thanks.

ouai
  • 150
  • 1
  • 10

1 Answers1

4

Can you try using the easy_isolate plugin? I tried here and took only 195ms to execute a code inside the isolate.

The Parallel.run works like the compute function. The plugin has well-explained documentation.

https://pub.dev/packages/easy_isolate

Lucas Britto
  • 355
  • 1
  • 8
  • Oh, didn't find that one. Literally made the same thing as a solution... Oh well. – ouai Aug 29 '21 at 14:31
  • Yep, it did ! Since there isn't another answer, I'm going to assume this is as good as it gets and close this. – ouai Aug 30 '21 at 18:23