hitTestPort method

ResolvedPortTarget? hitTestPort(
  1. DiagramPoint point, {
  2. double tolerance = 6,
})

Implementation

ResolvedPortTarget? hitTestPort(DiagramPoint point, {double tolerance = 6}) {
  final candidates = spatialIndex._query(
    DiagramRect.fromCenter(
      center: point,
      size: DiagramSize(tolerance * 2, tolerance * 2),
    ),
  );
  for (final element in candidates.reversed) {
    if (element is! ResolvedShape ||
        !element.definition.connection.usesPorts ||
        !_insideClippingAncestors(element, point)) {
      continue;
    }
    final port = element.portAt(point, tolerance: tolerance);
    if (port != null) return ResolvedPortTarget(shape: element, port: port);
  }
  return null;
}