addWithPaintOffset method

bool addWithPaintOffset (
  1. {@required Offset offset,
  2. @required Offset position,
  3. @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.

Se 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,
}) {
  assert(hitTest != null);
  return addWithRawTransform(
    transform: offset != null ? Matrix4.translationValues(-offset.dx, -offset.dy, 0.0) : null,
    position: position,
    hitTest: hitTest,
  );
}