labelBuilder property

LabelBuilder? labelBuilder
final

Optional builder for customizing connection label widgets.

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

The builder receives:

  • context: Build context
  • connection: The connection containing this label
  • label: The label being rendered
  • position: The calculated position rect for the label

Return null to use the default label widget with theme styling.

Example:

labelBuilder: (context, connection, label, position) {
  return Positioned(
    left: position.left,
    top: position.top,
    child: Container(
      padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
      decoration: BoxDecoration(
        color: connection.data?['priority'] == 'high'
            ? Colors.orange.shade100
            : Colors.white,
        borderRadius: BorderRadius.circular(4),
      ),
      child: Text(label.text),
    ),
  );
}

Implementation

final LabelBuilder? labelBuilder;