transformHitTests property

bool transformHitTests
final

Whether to transform registered hits into the child's resulting coordinate system.

When true, hit coordinates within the parent's bounds are transformed to match where the child appears visually after any transformation such as translation, rotation, scaling, or skewing.

When false, hit coordinates are not transformed, potentially causing taps to register in a different location relative to the child's visual position.

Important: Even when transformHitTests is true, children cannot receive events outside the parent's bounds. Hit testing always starts with the parent's own bounds check in RenderBox.hitTest. If the pointer is outside the parent's bounds, RenderBox.hitTestChildren is not invoked and the children are not considered for hit testing.

For interactive elements that need to be tappable outside their parent's original bounds, consider:

  • Expanding the parent widget's bounds to encompass the transformed child.
  • Using an OverlayEntry or OverlayPortal to place the widget in an Overlay.
  • Restructuring the widget hierarchy.

This example shows a Container that is scaled up. Even though it appears larger, taps are only registered within the original 100x100 area of the parent SizedBox.
link
Center(
  child: SizedBox(
    width: 100.0,
    height: 100.0,
    child: Transform.scale(
      scale: 2.0,
      child: GestureDetector(
        onTap: () => debugPrint('Tapped!'),
        child: const ColoredBox(
          color: Colors.purple,
        ),
      ),
    ),
  ),
)

Defaults to true.

Implementation

final bool transformHitTests;