addWithRawTransform method

bool addWithRawTransform({
  1. required Matrix4? transform,
  2. required Offset position,
  3. required BoxHitTest hitTest,
})

Transforms position to the local coordinate system of a child for hit-testing the child.

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.

Unlike addWithPaintTransform, the provided transform matrix is used directly to transform position without any pre-processing.

If transform is null it will be treated as the identity transform ad position is provided to the hitTest callback as-is.

The function returns the return value of the hitTest callback.

See also:

Implementation

bool addWithRawTransform({
  required Matrix4? transform,
  required Offset position,
  required BoxHitTest hitTest,
}) {
  final Offset transformedPosition = transform == null ?
      position : MatrixUtils.transformPoint(transform, position);
  if (transform != null) {
    pushTransform(transform);
  }
  final bool isHit = hitTest(this, transformedPosition);
  if (transform != null) {
    popTransform();
  }
  return isHit;
}