01 / Select TimeShariar Nafiz · 30 Min Meeting
Shariar Nafiz

Shariar Nafiz

30 Min Meeting

30m
Google Meet
SUN
MON
TUE
WED
THU
FRI
SAT
0

No open slots left today. Please choose another date on the calendar.

Instant Calendar Event · Google Meet
Back to Blogs
May 2, 20256 min read

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

FlutterPerformanceIsolates
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.

dart
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.

dart
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.

< 09 / Contact />

Have a product in mind? Let's build it.

Open to full-time engineering roles, AI-first architecture consulting, and product builds.