hitTest method

  1. @override
bool hitTest(
  1. DiagramPoint worldPoint, {
  2. double tolerance = diagramStrokeHitTolerance,
})
override

Closed outlines pick their interior; stroke outlines widen to tolerance, which defaults to their fixed pick radius.

Implementation

@override
bool hitTest(
  DiagramPoint worldPoint, {
  double tolerance = diagramStrokeHitTolerance,
}) {
  if (collapseControlBounds?.contains(worldToLocal(worldPoint)) == true) {
    return true;
  }
  if (super.hitTest(worldPoint, tolerance: tolerance)) return true;
  final local = worldToLocal(worldPoint);
  // A placed shape tests its untranslated lines, so picking and connector
  // clipping never force line geometry to be copied.
  if (_placement case final placed?) {
    final shifted = local - placed.origin;
    return placed.local.text?.lines.any(
          (line) => line.bounds.contains(shifted),
        ) ??
        false;
  }
  return text?.lines.any((line) => line.bounds.contains(local)) ?? false;
}