flutter-performance
Installation
SKILL.md
Flutter Performance Optimization
Goal
Analyzes and optimizes Flutter application performance by identifying jank, excessive rebuilds, and expensive rendering operations. Implements best practices for UI rendering, state management, and layout constraints. Utilizes Flutter DevTools, Chrome DevTools (for web), and integration tests to generate actionable performance metrics, ensuring frames render within the strict 16ms budget.
Decision Logic
Evaluate the target application using the following decision tree to determine the optimization path:
- Is the goal to establish a performance baseline?
- Yes: Implement an integration test using
traceActionandTimelineSummary. - No: Proceed to step 2.
- Yes: Implement an integration test using
- Is the application running on Web?
- Yes: Enable
debugProfileBuildsEnabledand use Chrome DevTools Performance panel. - No: Run the app on a physical device in
--profilemode and launch Flutter DevTools.
- Yes: Enable
- Which thread is showing jank (red bars > 16ms) in the DevTools Performance View?
- UI Thread: Optimize
build()methods, localizesetState(), useconstconstructors, and replace string concatenation withStringBuffer. - Raster (GPU) Thread: Minimize
saveLayer(),Opacity,Clip, andImageFilterusage. Pre-cache complex images usingRepaintBoundary. - Both: Start by optimizing the UI thread (Dart VM), as expensive Dart code often cascades into expensive rendering.
- UI Thread: Optimize