Skip to main content


I'm thinking about the new Isolate.run mechanism in Dart 2.19. For those that don't know it allows one to spawn a processing thread and return the result in one line. Thus having background work come back to you is as simple as an async/await but it won't block the main thread. Is there a major downside to liberally using this? Noodling on it for some post-network processing stuff I do in the main thread with asynchronous programming but that produces periodic jank... #flutter #DartLang https://api.flutter.dev/flutter/dart-isolate/Isolate/run.html
in reply to Hank G ☑️

If it's a frequent task, I think it's better to spawn a single isolate manually and talk to it when needed. Creating threads is expensive.
This entry was edited (1 year ago)
in reply to inicornie

Isolates aren't using some thread pooling concepts in the background?
in reply to Hank G ☑️

hm, I don't know actually. Didn't think of that...

Looking it up, seems like they are actually
This entry was edited (1 year ago)
in reply to Hank G ☑️

consider checking out Combine by a good friend of mine if you want to work with isolates. It basically makes using them a lot easier and cleaner

https://maksimka101.github.io/docusaurus-blog/blog/combine/

https://github.com/Maksimka101/combine/
in reply to arshak

Wow even easier than the new "run" stuff they added in 2.19? Definitely will thanks!
in reply to Hank G ☑️

I didn't check out the "run" stuff yet, but that's totally possible :)
It also makes it easy to use MethodChannels inside isolates
in reply to arshak

It looks like it is making it easier to use longer lived isolates. The "run" method is essentially a one off that returns the value just like if you did a regular await call on an async method.
in reply to Hank G ☑️

ah, so it’s a newer way of doing `compute`, I guess?

Yeah, Combine is good when you want to keep the isolate for some kind of tasks. For example, you could parse JSONs from API responses only when they are big enough (because otherwise it takes longer and doesn’t really affect the rendering)