optimize

Improves Flutter and Dart code performance, memory usage, and readability through profiling and refactoring.

548|29|Updated Feb 3, 2026
One-click install
npx skills add https://github.com/hacan359/tonkatsu_box --skill optimize-hacan359
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: optimize
Source: https://github.com/hacan359/tonkatsu_box/tree/main/.claude/skills/optimize
Command: npx skills add https://github.com/hacan359/tonkatsu_box --skill optimize-hacan359

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Flutter and Dart codebases often accumulate performance bottlenecks such as O(n²) algorithms, unnecessary widget rebuilds, memory leaks from uncancelled subscriptions, and sequential async calls. This Skill provides a structured process to find and fix these issues. ## Core Features & Use Cases - Profiling Guidance: Uses Flutter DevTools CPU profiler, memory inspector, and performance overlay to locate bottlenecks before changing code. - Algorithm and Memory Optimization: Replaces quadratic patterns with Set/Map lookups, eliminates object creation in loops, and enforces dispose() cleanup for subscriptions and controllers. - Widget and Async Optimization: Applies const constructors, ListView.builder, widget splitting, Future.wait parallelism, caching, and debouncing. - Use Case: A Flutter app's list screen stutters during scrolling. Use this Skill to profile the screen, switch to ListView.builder, extract const widgets, and verify frame times drop below 16ms. ## Quick Start Optimize the Flutter code in this project for performance and memory, then verify with flutter analyze and flutter test.

Frequently Asked Questions about optimize

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize Flutter app performance?

Start by profiling with Flutter DevTools in profile mode to find bottlenecks in CPU, memory, and frame rendering. Then reduce widget rebuilds with const constructors and ListView.builder, replace O(n²) algorithms with Set or Map lookups, and run heavy work in parallel with Future.wait.

How to reduce widget rebuilds in Flutter?

Use const constructors wherever possible so Flutter skips rebuilding identical widgets. Split large widgets so changing state only rebuilds the affected subtree, and use ListView.builder instead of ListView so only visible items are built.

How do I fix memory leaks in Dart and Flutter?

Cancel stream subscriptions and dispose controllers in the dispose() method of every StatefulWidget. Avoid creating objects inside loops or build methods, reuse instances like DateFormat, and avoid holding references to objects no longer needed.

How to run async operations in parallel in Dart?

Use Future.wait to execute multiple independent futures concurrently instead of awaiting them sequentially. For repeated calls like search input, add a debounce Timer, and cache results in a Map to avoid redundant network requests.

How do I verify Flutter optimizations did not break anything?

Run flutter analyze with fatal warnings and the full flutter test suite after refactoring. Then launch the app in profile mode and use the performance overlay to confirm frame rendering stays under 16ms for 60fps.