createSegmentsThroughWaypoints method
({List<PathSegment> segments, Offset start})
createSegmentsThroughWaypoints(
- List<
Offset> waypoints, - ConnectionPathParameters params
override
Creates segments 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 pointsparams: Original connection parameters for context (curvature, corner radius, etc.)
Returns: A tuple of start and segments that connect all waypoints according to the style's visual characteristics.
Implementation
@override
({Offset start, List<PathSegment> segments}) createSegmentsThroughWaypoints(
List<Offset> waypoints,
ConnectionPathParameters params,
) {
if (waypoints.isEmpty) {
return createDefaultSegments(params);
}
// If only start and end, use default path
if (waypoints.length == 2) {
return createDefaultSegments(params);
}
// Create orthogonal path through all waypoints
// We need to convert the arbitrary control points into orthogonal segments
final orthogonalWaypoints = _createOrthogonalWaypoints(waypoints);
// Generate segments with rounded corners
final effectiveCornerRadius = params.cornerRadius > 0
? params.cornerRadius
: defaultCornerRadius;
final segments = _generateSmoothSegments(
orthogonalWaypoints,
effectiveCornerRadius,
);
return (start: waypoints.first, segments: segments);
}