Flutter Concurrency
ASecurityYour app is freezing because large JSON parsing is CPU-bound work, and by default that work runs on Flutter's main isolate. When the main isolate spends too long decoding JSON, it blocks the event loop and the UI cannot paint frames, which shows up as jank or a full freeze. The fix is to move the parsing work off the main isolate. For a one-off heavy computation like decoding a large JSON payload, `Isolate.run()` is the right choice. Use this shape: ```dart import 'dart:convert'; import 'dart...
- 584 stars
- 0 votes
- 0 copies
- 2 views
- Added September 5, 2026
Security analysis
100/100Pro scans all 13 files and shows the line behind each finding
npx -y skills add HoangNguyen0403/agent-skills-standard --skill flutter-concurrency --agent claude-codeAre you the author of Flutter Concurrency?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-flutter-concurrency-agent-skills-standard)Your app is freezing because large JSON parsing is CPU-bound work, and by default that work runs on Flutter's main isolate. When the main isolate spends too long decoding JSON, it blocks the event loop and the UI cannot paint frames, which shows up as jank or a full freeze.
The fix is to move the parsing work off the main isolate. For a one-off heavy computation like decoding a large JSON payload, `Isolate.run()` is the right choice.
Use this shape:
```dart
import 'dart:convert';
import 'dart:isolate';
List<dynamic> _decodeJson(String rawJson) {
return jsonDecode(rawJson) as List<dynamic>;
}
Future<List<dynamic>> parseLargeJson(String rawJson) async {
return await Isolate.run(() => _decodeJson(rawJson));
}
```
Why this works:
- `async`/`await` alone would not fix the freeze, because it helps with non-blocking I/O, not heavy CPU work.
- `Isolate.run()` creates a background isolate for this one task, returns the result, and shuts down automatically.
- Keeping the decode function top-level or static is the safe pattern for isolate work.
A typical usage flow is:
1. Fetch or read the JSON string normally.
2. Pass the raw string into `parseLargeJson(...)`.
3. `await` the parsed result back on the main isolate.
4. Update UI after the computation finishes.
Example:
```dart
Future<void> loadItems() async {
final rawJson = await rootBundle.loadString('assets/large.json');
final items = await parseLargeJson(rawJson);
// setState / update notifier with items
}
```
Important constraints:
- Pass data in and out through function arguments and return values. Isolates do not share mutable memory.
- Keep the isolate entry logic focused on the heavy computation itself.
- Reserve `Isolate.spawn()` for long-lived workers that need ongoing background communication; it is more setup than you need for one large decode.
If your JSON is especially large, this is one of the clearest cases where parsing on the main isolate is an anti-pattern. Offloading it with `Isolate.run()` is the standard fix.
Files in this skill
- eval-1.baseline.md
- eval-1.with-skill.md
- eval-2.baseline.md
- eval-2.with-skill.md
- eval-3.baseline.md
- eval-3.with-skill.md
- trigger-1.md
- trigger-2.md
- trigger-3.md
- trigger-4.md
- trigger-5.md
- trigger-6.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.