buildAndCachePath method
Build (or retrieve cached) a ui.Path keyed by key.
Pass a stable key that encodes the data identity (e.g., a hash of the
series values + viewport dimensions). Call invalidatePath when data
changes.
final path = buildAndCachePath(
'line_0_${dataHash}_${viewport.width.toInt()}',
() => _buildLinePath(points, viewport),
);
canvas.drawPath(path, strokePaint(color, 2));
Implementation
ui.Path buildAndCachePath(String key, ui.Path Function() builder) {
return pathCache.getOrBuild(key, builder);
}