A talk on Dart concurrency
Async doesn't mean
in the background
Dart's event loop and isolates
Pedro MassangoDevFest Nürnberg 2026
By the end, you'll know why your app freezes.
await
Isolate.run
a long-lived isolate
01One worker
02One cashier, two queues
03A second shop
04Where are the threads?
05Putting it to work
01
One worker
Everything in your app waits its turn.
Your whole app runs on one worker.
Everyone waits in the same line.
Every frame gets 16 ms, and your code shares it.
Think of a shop with a single cashier.
Taps, network responses, timers and frames. One at a time.
8.3 ms at 120 Hz. Everything between two frames has to fit.
One slow customer blocks everyone behind them.
The frame is in the same line. It can't cut in.
Does async make this run in the background?
async means: this function may pause at an await.
primes.dart
No await, no pause point.
Runs start to finish on main.
And an async function runs synchronously until its first await.
await fixes waiting. It doesn't fix working.
02
One cashier, two queues
The cashier keeps sticky notes, and clears them all before the next customer.
There are two queues, not one.
Event queue
customers in line
- taps and gestures
- network and file I/O results
Timer, Future(), Future.delayed()
- messages from other isolates
- frames, from the engine
Microtask queue
the cashier's sticky notes
scheduleMicrotask()
Future.microtask()
- the code after an
await
.then() on a completed future
After each event, the loop drains every microtask, even ones added along the way.
take one event→run all microtasks→take one event→ ...
What does this print?
Hands up for one:
A1 2 3 4 5 6
B1 6 2 3 4 5
C1 6 3 4 2 5
C · 1 6 3 4 2 5
Sync code first. Then every microtask. Then the next event.
Microtasks always go first. Even before the frame.
Awaiting a finished future never lets the frame through.
Need a frame through? Get back in the event queue.
✓
await Future.delayed(Duration.zero);a timer: you rejoin the line behind the frame
Yield every few milliseconds of work, not every item. It's a workaround:
for real CPU work, use another isolate.
03
A second shop
Same rules. Separate memory.
An isolate has its own event loop and its own memory.
Main isolate
the shop Flutter lives in
event loop
microtasksevents
Objects · privatewidgets, state, controllers, BuildContext, plugins, orders
Worker isolate
pure Dart, no Flutter
its own event loop
microtasksevents
Objects · privateits own fresh globals, and only what you sent it orders (a copy)
SendPort.send(job)
result
copied, never shared
Sending is copying. Copying costs time.
measured live: structuredClone() in this browser. Illustrative, same idea as SendPort.send: a deep copy. Measure Dart with DevTools.
Coming back is nearly freeIsolate.run ends the worker and hands its result over. No copy.
Spawning isn't freeCheap since Dart 2.15, not zero. Measure on your slowest phone.
Not everything travelsReceivePorts, sockets, native handles. Capture this in a State and it usually fails outright.
04
But where are the threads?
If you're coming from Android or the JVM, this is the part you were waiting for.
A thread is a second cashier. An isolate is a second shop.
Dart chose isolation. You trade locks for copies.
Write coroutines? You already know this.
suspend fun≈async: may pause. Doesn't move.
Dispatchers.Main≈the main isolate: one cashier, and it draws the UI
withContext(Dispatchers.Default)≈Isolate.run, except the data is copied, not shared
Threads · JVM, Android
Two cashiers,
one storeroom.
shared memorylocksvolatiledata races
Isolates · Dart
Two shops,
two storerooms.
no shared memorymessagescopiesno locks
Dart still runs on threads. You just never hold one.
platform threadyour main isolate runs here, next to your Kotlin and Swift code
raster threadturns each frame's layers into GPU work
io threadimage decoding and other engine I/O
VM thread poolruns your other isolates, one thread at a time each
No Thread class. No shared heap. An isolate isn't even pinned to one thread.
On the web there are no isolates at all: compute runs on the main thread.
05
Putting it to work
Choose the tool, check it, then fix the freeze.
Three questions pick the tool.
Is it waiting on the outside world?network · disk · timers · platform channels
YES
awaitstay on main, it's free while waiting
NO
Is it longer than a frame?~16 ms · ~8 ms at 120 Hz · on a slow phone
NO
leave it on mainsync code is fine when it's small
YES
Is it a one-off job?parse this, resize that
YES
Isolate.runspawn, run, return, done
NO, OVER AND OVER
a long-lived isolatespawn once, keep the ports open
Not sure if it blocks? Check.
DevTools, Performance view.
Find the red frame, then look at which bar is red.
UI: your Dart code. An isolate helps.
Raster: drawing, like shaders. An isolate won't help.
Sync work hiding in plain sight:
*Sync I/O · jsonDecode · utf8.decode
sorting · regex · crypto · image work
Will it block?
1 / 2
LINE 2 BLOCKSReading is waiting. Decoding is working.
2 / 2
BLOCKS FRAMESEvery await here is a microtask. Microtasks never let a frame through.
Off the main isolate. The dot never stops.
export_screen.dart
Same work. Different shop.
If you remember three things.
- 01async lets a function pause. It doesn't move it anywhere.
- 02await fixes waiting, not working.Network, disk and timers are free. Loops and parsing are not, and neither is awaiting finished futures in a loop.
- 03Working longer than a frame? Isolate.run.Doing it over and over? Keep one isolate alive.
Thank you.
Slides
LinkedIn