createOptimizedHitTestPath method

Path createOptimizedHitTestPath(
  1. List<Offset> waypoints,
  2. double tolerance
)

Create optimized hit test path from exact waypoints

Implementation

Path createOptimizedHitTestPath(List<Offset> waypoints, double tolerance) {
  if (waypoints.length <= 2) {
    // Simple case: single segment
    return _createStepSegmentHitArea(
      waypoints.first,
      waypoints.last,
      tolerance,
    );
  }

  final combinedPath = Path();

  // Create rectangles for all segments
  for (int i = 0; i < waypoints.length - 1; i++) {
    final segmentPath = _createStepSegmentHitArea(
      waypoints[i],
      waypoints[i + 1],
      tolerance,
    );
    combinedPath.addPath(segmentPath, Offset.zero);
  }

  return combinedPath;
}