paint method

  1. @override
void paint(
  1. Canvas canvas,
  2. Size size
)
override

Paints all connections in the node flow.

This method iterates through all connections and renders their paths and endpoint markers. It skips connections whose nodes are not found (e.g., during deletion operations).

Note: Labels are intentionally NOT rendered here - they are rendered in a separate layer for better performance and to avoid text rendering issues during rapid repaints.

Implementation

@override
void paint(Canvas canvas, Size size) {
  // Use the shared cached connection painter
  // This ensures paths are cached and reused for both painting and hit testing

  // Always use all connections - let InteractiveViewer handle visibility
  // This avoids expensive visibility computation during panning
  final connectionsToRender = store.connections;

  // Get current animation value
  final animationValue = animation?.value;

  // Paint only connection lines and endpoints (no labels)
  // Labels are now rendered in a separate layer for better performance
  for (final connection in connectionsToRender) {
    final sourceNode = store.getNode(connection.sourceNodeId);
    final targetNode = store.getNode(connection.targetNodeId);

    if (sourceNode == null || targetNode == null) continue;

    final isSelected = store.selectedConnectionIds.contains(connection.id);

    // Paint connection without labels using cached painter
    connectionPainter.paintConnection(
      canvas,
      connection,
      sourceNode,
      targetNode,
      isSelected: isSelected,
      animationValue: animationValue,
    );
  }
}