flutter-concurrency
Installation
SKILL.md
Dart Concurrency and Isolates
Priority: P1
Core Concepts
Dart uses a single-threaded event loop. All Flutter code runs on the Main Isolate by default. Blocking it causes jank.
- async/await: For non-blocking I/O (network, file). The event loop continues while waiting.
- Isolates: Dart's lightweight threads with isolated memory. Communicate via message passing only.
Decision Matrix
| Condition | Approach |
|---|---|
| I/O bound (HTTP, database) | async/await on Main Isolate |
| CPU-bound, < 16ms | async/await on Main Isolate |
| CPU-bound, one-off heavy task | Isolate.run() |
| Continuous background processing | Isolate.spawn() with ports |