running-flutter-isolates
Installation
SKILL.md
Flutter Isolate
Goal
Move heavy computations off the main isolate to prevent UI jank (>16ms frame gaps), using the simplest API that fits the use case.
Decision: Which API to Use?
Use compute() when: |
Use Isolate.spawn() when: |
|---|---|
| ✅ One-off computation | ✅ Long-lived worker needed |
| ✅ Simple serializable data | ✅ Multiple messages over time |
| ✅ Auto-cleanup desired | ✅ Custom messaging protocol |
| ✅ Web compatibility required | ✅ Avoid repeated spawn overhead |
| ❌ NOT for long-running tasks | ❌ NOT for single one-shot tasks |
| Additional Scenarios | API |
|---|---|
| One-shot, single return value (Dart 2.19+) | Isolate.run() |
| Need platform plugins in background | BackgroundIsolateBinaryMessenger |