LabelBuilder typedef

LabelBuilder = Widget Function(BuildContext context, Connection connection, ConnectionLabel label, Rect position, VoidCallback? onTap)

Builder function type for customizing connection label widgets.

This typedef defines the signature for custom label builders that can be provided to NodeFlowEditor to customize how connection labels are rendered.

Parameters:

  • context: The build context
  • connection: The connection containing this label
  • label: The label being rendered
  • position: The calculated position rect for the label (includes size)
  • onTap: Optional tap callback that handles selection with modifier key support. Custom widgets can use this to get the standard selection behavior, or ignore it to implement custom tap handling.

Example:

LabelBuilder myLabelBuilder = (context, connection, label, position, onTap) {
  return GestureDetector(
    onTap: onTap, // Use the provided tap handler for selection
    child: Container(
      padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
      decoration: BoxDecoration(
        color: Colors.amber.shade100,
        borderRadius: BorderRadius.circular(12),
      ),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          Icon(Icons.bolt, size: 14),
          SizedBox(width: 4),
          Text(label.text),
        ],
      ),
    ),
  );
};

Implementation

typedef LabelBuilder =
    Widget Function(
      BuildContext context,
      Connection connection,
      ConnectionLabel label,
      Rect position,
      VoidCallback? onTap,
    );