addWithPaintOffset method
- required Offset? offset,
- required Offset position,
- required BoxHitTest hitTest,
Convenience method for hit testing children, that are translated by an Offset.
The actual hit testing of the child needs to be implemented in the
provided hitTest
callback, which is invoked with the transformed
position
as argument.
This method can be used as a convenience over addWithPaintTransform if
a parent paints a child at an offset
.
A null value for offset
is treated as if Offset.zero was provided.
The function returns the return value of the hitTest
callback.
See also:
- addWithPaintTransform, which takes a generic paint transform matrix and documents the intended usage of this API in more detail.
Implementation
bool addWithPaintOffset({
required Offset? offset,
required Offset position,
required BoxHitTest hitTest,
}) {
final Offset transformedPosition = offset == null ? position : position - offset;
if (offset != null) {
pushOffset(-offset);
}
final bool isHit = hitTest(this, transformedPosition);
if (offset != null) {
popTransform();
}
return isHit;
}