Flutter performance optimizer
Skill Desquared/agents-rules-skills/skills/flutter-performance-optimizer
Use when Flutter UI has jank, slow scrolling, excessive rebuilds, or memory leaks. Also use when optimizing lists, animations, or complex widget trees, or when the user asks about Flutter rendering performance.From its SKILL.md
npx -y skills add Desquared/agents-rules-skills --skill flutter-performance-optimizerAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
1.6 KB, as published. Nobody here has run it
Optimization Skill
Quick Wins
// 1. const: const Text('Title') vs Text('Title')
// 2. Narrow BlocBuilder: Scaffold(body: BlocBuilder(...))
// vs BlocBuilder(builder: (ctx, state) => Scaffold(...))
// 3. buildWhen: buildWhen: (prev, curr) => prev.data != curr.data
// 4. ListView.builder vs ListView(children: [])
// 5. Keys: key: ValueKey(items[i].id)
// 6. Batch API:
// ❌ for (item in items) await api.fetch(item.id);
// ✅ await Future.wait(items.map((i) => api.fetch(i.id)));
// ✅✅ await api.fetchBatch(ids);
// 7. Debounce:
Timer? _debounce;
void onSearchChanged(String q) {
_debounce?.cancel();
_debounce = Timer(Duration(milliseconds: 300), () => _search(q));
}
// 8. Heavy work: compute(_heavy, data) in Bloc, NOT in build()
// 9. Images: CachedNetworkImage with width/height
// 10. Memory leaks:
@override Future<void> close() { _controller.close(); return super.close(); }
@override void dispose() { _timer?.cancel(); super.dispose(); }
Common Issues
- BlocBuilder wraps entire screen → Narrow scope
- Missing const → Add const
- No buildWhen → Filter rebuilds
- ListView without .builder → Use .builder
- Sequential API calls → Batch or parallel
- Heavy computation in build() → Move to Bloc/isolate
- Streams/timers not closed → Dispose properly
Diagnostics
flutter run --profile --trace-skia
# DevTools → Memory, Performance