Mastering 120 FPS in Flutter: RepaintBoundaries and DevTools Profiling
Achieving constant 60 FPS or 120 FPS on high-refresh-rate ProMotion displays requires understanding Flutter’s rendering pipeline. Too often, developers blame the framework when performance stutters, when in reality an unisolated widget tree is triggering continuous rebuilds on the raster thread.
The Three Trees
Flutter manages three distinct trees:
- Widget Tree: Immutable blueprint of configurations. Cheap to create.
- Element Tree: The manager orchestrating lifecycle and diffing.
- RenderObject Tree: The expensive layer responsible for layout sizing, positioning, and paint commands.
When state changes high up in the tree without boundary isolation, the engine must repaint extensive parts of the layer tree.
When to Reach for RepaintBoundary
A RepaintBoundary creates a separate display list layer. When children change, only that layer repaints instead of bubbling up to ancestors:
// Isolating a high-frequency animation or canvas element
RepaintBoundary(
child: AnimatedBuilder(
animation: _pulseAnimation,
builder: (context, child) {
return CustomPaint(
painter: WaveformPainter(progress: _pulseAnimation.value),
);
},
),
)
The Tradeoff
Never wrap every small widget in a RepaintBoundary. Each boundary allocates a separate layer surface in GPU memory. Use it strategically for:
- Scrollable list items with rich animations
- Live camera or video texture overlays
- Custom vector canvas graphs with frequent updates
Diagnosing with Flutter DevTools
Open Flutter DevTools CPU and Performance overlay:
- Enable Highlight repaints (
debugRepaintRainbowEnabled = true). If unrelated sections flash colors when interacting with a slider, you have boundary leakage. - Check the Raster thread time. If raster time exceeds 8.3ms on a 120Hz display, you will drop frames.
- Replace heavy runtime
BackdropFiltershaders inside repeating list items with pre-rendered assets or cached elevation shaders.
By respecting the render pipeline and profiling continuously, your Flutter apps feel native, instant, and refined.
Written by Hridoy Khandakar
Senior Mobile App Developer with deep experience in Flutter & Dart. Building production cross-platform apps that don't compromise on speed or feel.
More about my work →