CustomChartPainterBase class abstract

Convenience base class for custom chart painters.

Extends ChartPainterBase so your painter gets free access to paintCache, textPainterCache, colorCache, theme helpers, and axis drawing utilities.

Usage:

class MyPainter extends CustomChartPainterBase {
  final double progress;
  MyPainter(Map<String,dynamic> data, ChartTheme theme, this.progress)
      : super(data: data, theme: theme);

  @override
  void paint(Canvas canvas, Size size) {
    // your drawing code here — use paintCache, textPainterCache, etc.
  }

  @override
  bool shouldRepaintChart(covariant MyPainter old) =>
      old.progress != progress;
}
Inheritance

Constructors

CustomChartPainterBase({required Map<String, dynamic> data, required ChartTheme theme})

Properties

axisPaint Paint
no setterinherited
colorCache ColorCache
no setterinherited
crosshairPaint Paint
no setterinherited
data Map<String, dynamic>
final
gridPaint Paint
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
paintCache PaintCache
no setterinherited
pathCache PathCache
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
semanticsBuilder SemanticsBuilderCallback?
Returns a function that builds semantic information for the picture drawn by this painter.
no setterinherited
textPainterCache TextPainterCache
no setterinherited
theme ChartTheme
finalinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be notified when it is time to repaint.
inherited
buildAndCachePath(String key, Path builder()) Path
Build (or retrieve cached) a ui.Path keyed by key.
inherited
clipToViewport(Canvas canvas, ChartViewport viewport, void body()) → void
Clip canvas to the viewport plot area for the duration of body.
inherited
drawCrosshair(Canvas canvas, ChartViewport viewport, double cx) → void
Draw a vertical crosshair line at canvas-x cx.
inherited
drawDashedLine(Canvas canvas, Offset start, Offset end, Paint paint, {double dash = 6, double gap = 4}) → void
Draw a dashed line segment with paint.
inherited
drawHorizontalCrosshair(Canvas canvas, ChartViewport viewport, double cy) → void
Draw a horizontal crosshair line at canvas-y cy.
inherited
drawHorizontalGrid(Canvas canvas, ChartViewport viewport, List<double> yTicks, {bool dashed = true}) → void
Draw horizontal grid lines across viewport for yTicks.
inherited
drawTooltip(Canvas canvas, Size canvasSize, Offset anchor, List<String> lines) → void
Draw a rounded-rect tooltip bubble.
inherited
drawVerticalGrid(Canvas canvas, ChartViewport viewport, List<double> xPositions, {bool dashed = false}) → void
Draw vertical grid lines for each x category in xPositions.
inherited
drawXAxisLabels(Canvas canvas, ChartViewport viewport, List<String> xLabels, List<double> xPositions) → void
Draw bottom X-axis labels for xLabels at xPositions.
inherited
drawXAxisLabelsRotated(Canvas canvas, ChartViewport viewport, List<String> xLabels, List<double> xPositions, {double angleDeg = -45}) → void
Draw rotated X-axis labels (e.g., for many categories).
inherited
drawYAxisLabels(Canvas canvas, ChartViewport viewport, List<double> yTicks, String formatter(double)) → void
Draw left Y-axis labels for yTicks.
inherited
fillPaint(Color color) Paint
inherited
fillPaintMutable(Color color) Paint
Returns a new mutable fill paint — safe to add shaders, maskFilters etc.
inherited
hitTest(Offset position) bool?
Called whenever a hit test is being performed on an object that is using this custom paint delegate.
inherited
invalidatePath(String key) → void
inherited
invalidatePathsWithPrefix(String prefix) → void
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
paint(Canvas canvas, Size size) → void
Called whenever the object needs to paint. The given Canvas has its coordinate space configured such that the origin is at the top left of the box. The area of the box is the size of the size argument.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that the object notifies when it is time to repaint.
inherited
shouldRebuildSemantics(covariant CustomPainter oldDelegate) bool
Called whenever a new instance of the custom painter delegate class is provided to the RenderCustomPaint object, or any time that a new CustomPaint object is created with a new instance of the custom painter delegate class (which amounts to the same thing, because the latter is implemented in terms of the former).
inherited
shouldRepaint(covariant ChartPainterBase old) bool
Subclasses should override shouldRepaintChart instead.
inherited
shouldRepaintChart(covariant ChartPainterBase old) bool
Return true if chart-specific state (data, selection, animation value…) has changed. Keep this as cheap as possible — reference equality is fine.
inherited
strokePaint(Color color, double width) Paint
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited