createHitTestPath method

  1. @override
Path createHitTestPath(
  1. Path originalPath,
  2. double tolerance, {
  3. ConnectionPathParameters? pathParams,
})
override

Creates an expanded path for hit testing The base implementation provides a simple stroke-based expansion

pathParams - Optional parameters used to create the original path. Some connection styles can use these to create more optimized hit test paths.

Implementation

@override
Path createHitTestPath(
  Path originalPath,
  double tolerance, {
  ConnectionPathParameters? pathParams,
}) {
  // Use exact bend points from the path calculator
  if (pathParams == null) {
    // This shouldn't happen in normal usage
    return Path()..addRect(originalPath.getBounds().inflate(tolerance));
  }

  final bendPoints = getExactBendPoints(pathParams);
  if (bendPoints == null || bendPoints.length < 2) {
    return Path()..addRect(originalPath.getBounds().inflate(tolerance));
  }

  return _createStepHitAreas(bendPoints, tolerance);
}