createGroupNode method

GroupNode<T> createGroupNode({
  1. required String title,
  2. required Offset position,
  3. required Size size,
  4. required T data,
  5. String? id,
  6. Color color = const Color(0xFF2196F3),
  7. GroupBehavior behavior = GroupBehavior.bounds,
  8. Set<String>? nodeIds,
  9. EdgeInsets padding = kGroupNodeDefaultPadding,
  10. List<Port> inputPorts = const [],
  11. List<Port> outputPorts = const [],
})

Creates and adds a group node that visually groups multiple nodes.

Group nodes create visual boundaries that can contain nodes. The behavior determines how node membership is managed (see GroupBehavior).

Parameters:

  • title: Title displayed at the top of the group
  • position: Position in graph coordinates
  • size: Size of the group
  • data: Custom data of type T associated with this node
  • id: Optional custom ID (auto-generated if not provided)
  • color: Background color of the group (default: blue)
  • behavior: How the group manages node membership (default: bounds)
  • nodeIds: Initial set of node IDs for explicit/parent behavior
  • padding: Padding around member nodes (default: kGroupNodeDefaultPadding)
  • inputPorts: Optional input ports for subflow patterns
  • outputPorts: Optional output ports for subflow patterns

Returns the created GroupNode.

Example:

controller.createGroupNode(
  title: 'Input Processing',
  position: Offset(100, 100),
  size: Size(400, 300),
  data: MyNodeData(),
  color: Colors.blue,
);

Implementation

GroupNode<T> createGroupNode({
  required String title,
  required Offset position,
  required Size size,
  required T data,
  String? id,
  Color color = const Color(0xFF2196F3), // Blue
  GroupBehavior behavior = GroupBehavior.bounds,
  Set<String>? nodeIds,
  EdgeInsets padding = kGroupNodeDefaultPadding,
  List<Port> inputPorts = const [],
  List<Port> outputPorts = const [],
}) {
  final node = GroupNode<T>(
    id: id ?? 'group-${DateTime.now().millisecondsSinceEpoch}',
    title: title,
    position: position,
    size: size,
    data: data,
    color: color,
    behavior: behavior,
    nodeIds: nodeIds,
    padding: padding,
    inputPorts: inputPorts,
    outputPorts: outputPorts,
  );
  addNode(node);
  return node;
}