getConnectionPath method

Path? getConnectionPath(
  1. String connectionId
)

Gets the rendered path for a connection.

Returns null if the connection doesn't exist or the painter is not initialized. The path is in world coordinates.

Example:

final path = controller.getConnectionPath('conn1');
if (path != null) {
  // Use path for custom rendering or hit testing
}

Implementation

Path? getConnectionPath(String connectionId) {
  if (!isConnectionPainterInitialized || _theme == null) return null;

  final connection = getConnection(connectionId);
  if (connection == null) return null;

  final sourceNode = _nodes[connection.sourceNodeId];
  final targetNode = _nodes[connection.targetNodeId];
  if (sourceNode == null || targetNode == null) return null;

  return _connectionPainter!.pathCache.getOrCreatePath(
    connection: connection,
    sourceNode: sourceNode,
    targetNode: targetNode,
    connectionStyle: _theme!.connectionTheme.style,
  );
}