ConnectionStyleBuilder<T, C> typedef

ConnectionStyleBuilder<T, C> = ConnectionStyle? Function(Connection<C> connection, Node<T> sourceNode, Node<T> targetNode)

Builder function for dynamic connection style selection.

This callback is invoked for each connection during rendering to determine which ConnectionStyle (path renderer) to use. It receives both the connection and its source/target nodes, enabling dynamic style selection based on node state or connection data.

Type Parameters

  • T: The type of data stored in nodes
  • C: The type of data stored in connections

Return Value

Return null to use the connection's default style or theme style. Return a ConnectionStyle instance (e.g., ConnectionStyles.bezier) to override the path rendering for this connection.

Example

connectionStyleBuilder: (connection, sourceNode, targetNode) {
  // Use bezier for error connections, smoothstep otherwise
  if (sourceNode.data?.hasError == true) {
    return ConnectionStyles.bezier;
  }
  return null; // Use default
}

Implementation

typedef ConnectionStyleBuilder<T, C> =
    ConnectionStyle? Function(
      Connection<C> connection,
      Node<T> sourceNode,
      Node<T> targetNode,
    );