pushTransform method Null safety

  1. @protected
void pushTransform(
  1. Matrix4 transform
)
protected">@protected

Pushes a new transform matrix that is to be applied to all future HitTestEntrys added via add until it is removed via popTransform.

This method is only to be used by subclasses, which must provide coordinate space specific public wrappers around this function for their users (see BoxHitTestResult.addWithPaintTransform for such an example).

The provided transform matrix should describe how to transform PointerEvents from the coordinate space of the method caller to the coordinate space of its children. In most cases transform is derived from running the inverted result of RenderObject.applyPaintTransform through PointerEvent.removePerspectiveTransform to remove the perspective component.

If the provided transform is a translation matrix, it is much faster to use pushOffset with the translation offset instead.

HitTestables need to call this method indirectly through a convenience method defined on a subclass before hit testing a child that does not have the same origin as the parent. After hit testing the child, popTransform has to be called to remove the child-specific transform.

See also:

Implementation

@protected
void pushTransform(Matrix4 transform) {
  assert(transform != null);
  assert(
    _debugVectorMoreOrLessEquals(transform.getRow(2), Vector4(0, 0, 1, 0)) &&
    _debugVectorMoreOrLessEquals(transform.getColumn(2), Vector4(0, 0, 1, 0)),
    'The third row and third column of a transform matrix for pointer '
    'events must be Vector4(0, 0, 1, 0) to ensure that a transformed '
    'point is directly under the pointing device. Did you forget to run the paint '
    'matrix through PointerEvent.removePerspectiveTransform? '
    'The provided matrix is:\n$transform',
  );
  _localTransforms.add(_MatrixTransformPart(transform));
}