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.

The position argument may be null, which will be forwarded to the hitTest callback as-is. Using null as the position can be useful if the child speaks a different hit test protocol then the parent and the position is not required to do the actual hit testing in that protocol.

Se also:

Implementation

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