createPathThroughWaypoints method

  1. @override
Path createPathThroughWaypoints(
  1. List<Offset> waypoints,
  2. ConnectionPathParameters params
)
override

Creates a path through the given waypoints.

This method is called when control points are provided or when the algorithmic path has been converted to waypoints for editing.

Parameters:

  • waypoints: List of points the path should pass through, including start and end points
  • params: Original connection parameters for context (curvature, corner radius, etc.)

Returns: A Path that connects all waypoints according to the style's visual characteristics (e.g., smooth curves, sharp angles, etc.)

Implementation

@override
Path createPathThroughWaypoints(
  List<Offset> waypoints,
  ConnectionPathParameters params,
) {
  if (waypoints.isEmpty) {
    return createDefaultPath(params);
  }

  // If only start and end, use default path
  if (waypoints.length == 2) {
    return createDefaultPath(params);
  }

  // Create orthogonal path through all waypoints
  // We need to convert the arbitrary control points into orthogonal segments
  final orthogonalWaypoints = _createOrthogonalWaypoints(waypoints);

  // Generate smooth path with rounded corners
  return _generateSmoothPath(
    orthogonalWaypoints,
    params.cornerRadius > 0 ? params.cornerRadius : defaultCornerRadius,
  );
}