SelectionPainter class abstract
To implement a custom selection painter, either subclass or implement this interface to define your custom paint delegate. SelectionPainter 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 either:
- Extend this class and supply a
repaint
argument to the constructor of the SelectionPainter, where that object notifies its listeners when it is time to repaint. - Extend Listenable (e.g. via ChangeNotifier) and implement SelectionPainter, so that the object itself provides the notifications directly.
In either case, the Selectable widget or RenderSelectable
render object
will listen to the Listenable 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.
- Inheritance
-
- Object
- Listenable
- SelectionPainter
- Implementers
Constructors
- SelectionPainter({Listenable? repaint})
-
Creates a custom selection painter.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be notified when it is time to repaint.
override
-
hitTest(
Offset position) → bool? - Called whenever a hit test is being performed on an object that is using this custom paint delegate.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
paint(
Canvas canvas, Size size, Selection selection) → void -
Called whenever the object needs to paint. The 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. -
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that the
object notifies when it is time to repaint.
override
-
shouldRepaint(
covariant SelectionPainter oldDelegate) → bool -
Called whenever a new instance of the custom painter delegate class is
provided to the
RenderSelectable
object, or any time that a new Selectable 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). -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited