paintConnection method

void paintConnection(
  1. Canvas canvas,
  2. Connection connection,
  3. Node sourceNode,
  4. Node targetNode, {
  5. bool isSelected = false,
  6. double? animationValue,
  7. ConnectionStyleOverrides? styleOverrides,
})

Implementation

void paintConnection(
  Canvas canvas,
  Connection connection,
  Node sourceNode, // Can be either Node or ObservableNode
  Node targetNode, { // Can be either Node or ObservableNode
  bool isSelected = false,
  double? animationValue,
  ConnectionStyleOverrides? styleOverrides,
}) {
  // Get effective style from connection instance or theme
  final effectiveStyle = connection.getEffectiveStyle(
    theme.connectionTheme.style,
  );

  // Get or create path using the cache with connection style
  final path = _pathCache.getOrCreatePath(
    connection: connection,
    sourceNode: sourceNode,
    targetNode: targetNode,
    connectionStyle: effectiveStyle, // Use effective style
  );

  if (path == null) {
    return; // Failed to create path
  }

  // Draw the connection using the cached path
  _drawConnectionWithPath(
    canvas,
    connection,
    path,
    sourceNode,
    targetNode,
    isSelected: isSelected,
    animationValue: animationValue,
    styleOverrides: styleOverrides,
  );
}