portBuilder property

PortBuilder<T>? portBuilder
final

Optional builder for customizing individual port widgets.

This function is called for each port in every node, allowing you to customize port appearance based on the port data, node, or any other application-specific logic.

The builder receives:

  • context: Build context
  • node: The node containing this port
  • port: The port being rendered
  • isOutput: Whether this is an output port (true) or input port (false)
  • isConnected: Whether the port currently has connections
  • isHighlighted: Whether the port is being hovered during connection drag

Return null to use the default PortWidget with theme styling.

Example:

portBuilder: (context, node, port, isOutput, isConnected, isHighlighted) {
  // Color ports based on data type
  final color = port.name.contains('error')
      ? Colors.red
      : null; // Use theme default

  return PortWidget(
    port: port,
    theme: Theme.of(context).extension<NodeFlowTheme>()!.portTheme,
    isConnected: isConnected,
    isHighlighted: isHighlighted,
    color: color,
  );
}

Implementation

final PortBuilder<T>? portBuilder;