The interface used by CustomPaint (in the widgets library) and RenderCustomPaint (in the rendering library).

To implement a custom painter, subclass this interface to define your custom paint delegate. CustomPaint subclasses must implement the paint and shouldRepaint methods, and may optionally also implement the hitTest method.

The paint method is called whenever the custom object needs to be repainted.

The shouldRepaint method is called when a new instance of the class is provided, to check if the new instance actually represents different information.

The most efficient way to trigger a repaint is to supply a repaint argument to the constructor of the CustomPainter. The custom object will listen to this animation and repaint whenever the animation ticks, avoiding both the build and layout phases of the pipeline.

The hitTest method is called when the user interacts with the underlying render object, to determine if the user hit the object or missed it.

Constructors

CustomPainter({Listenable repaint })

Creates a custom painter.

const

Properties

hashCode int

Get a hash code for this object.

read-only, inherited
runtimeType Type

A representation of the runtime type of the object.

read-only, inherited

Operators

operator ==(other) bool

The equality operator.

inherited

Methods

hitTest(Point position) bool

Called whenever a hit test is being performed on an object that is using this custom paint delegate.

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.

shouldRepaint(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).

noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.

inherited
toString() String

Returns a string representation of this object.

inherited