Reducing CPU/GPU Load by ~40% in Live Flutter Candlestick Charts

When rendering live WebSocket market ticks in a mobile trading or analytics app, decoding JSON payloads, recomputing OHLC buckets, and repainting adjacent widgets on the UI thread quickly blows through the 8.3ms frame budget on 120Hz displays.
Offloading Candle Aggregation to a Background Isolate
Instead of parsing market ticks and calculating moving averages inside build() or ChangeNotifier listeners, stream raw tick batches into a dedicated worker Isolate that returns pre-normalized candle structs ready for the canvas.
Future<List<NormalizedCandle>> computeVisibleGeometry(
RawTickBatch batch,
) async {
return Isolate.run(() {
final candles = aggregateOhlc(batch.ticks, batch.interval);
return normalizeToViewport(candles, batch.minPrice, batch.maxPrice);
});
}Isolating Canvas Repaints with RepaintBoundary
Even a fast CustomPainter drags down frame times if crosshair gestures or live price badges force parent order-book lists to rasterize again. Wrapping the canvas inside RepaintBoundary and separating static gridlines from the active price ticker keeps GPU layer uploads minimal.
RepaintBoundary(
child: CustomPaint(
isComplex: true,
willChange: true,
painter: CandlestickPainter(
candles: visibleCandles,
crosshairOffset: pointerNotifier.value,
),
),
)- Pre-allocate Paint objects outside paint() so 60/120 FPS ticks generate zero GC pressure.
- Drive crosshair overlays through a ValueListenable passed directly to the CustomPainter repaint hook—never setState() the whole screen.
- Cull off-screen historical candles before iterating drawRect / drawLine calls.
Production Result
In Bitcoin Canvas, pairing Isolate preprocessing with CustomPainter and RepaintBoundary cut CPU/GPU overhead by ~40% during high-frequency WebSocket updates.