flutter-performance
Identifies and eliminates performance bottlenecks in Flutter apps through systematic profiling and targeted optimization.
- Provides a decision tree to diagnose jank on UI thread, Raster (GPU) thread, or both, with specific fixes for each
- Includes integration test templates using
traceActionandTimelineSummaryto establish performance baselines and measure frame budgets - Covers UI optimization (localizing state, const constructors, StringBuffer usage) and Raster optimization (replacing Opacity widgets, avoiding expensive clipping)
- Addresses layout inefficiencies, framework breaking changes with LayoutBuilder/OverlayEntry, and web-specific profiling via Chrome DevTools
- Enforces constraints: profile in
--profilemode only, avoid operator overrides on Widgets, and use lazy builders for long lists
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
Instructions
More from flutter/skills
flutter-building-layouts
Builds Flutter layouts using the constraint system and layout widgets. Use when creating or refining the UI structure of a Flutter application.
10.6Kflutter-architecting-apps
Architects a Flutter application using the recommended layered approach (UI, Logic, Data). Use when structuring a new project or refactoring for scalability.
10.4Kflutter-animating-apps
Implements animated effects, transitions, and motion in a Flutter app. Use when adding visual feedback, shared element transitions, or physics-based animations.
9.6Kflutter-managing-state
Manages application and ephemeral state in a Flutter app. Use when sharing data between widgets or handling complex UI state transitions.
9.6Kflutter-theming-apps
Customizes the visual appearance of a Flutter app using the theming system. Use when defining global styles, colors, or typography for an application.
9.5Kflutter-implementing-navigation-and-routing
Handles routing, navigation, and deep linking in a Flutter application. Use when moving between screens or setting up URL-based navigation.
9.3K