selectedNodesBounds property
Rect?
get
selectedNodesBounds
Gets the bounding rectangle that encompasses all selected nodes in world coordinates.
Returns null if no nodes are selected.
This is useful for operations like "fit selected nodes to view" or calculating the area occupied by the selection.
Returns a Rect containing all selected nodes, or null if nothing is selected.
Implementation
Rect? get selectedNodesBounds {
if (_selectedNodeIds.isEmpty) return null;
final selectedNodes = _selectedNodeIds
.map((id) => _nodes[id])
.where((node) => node != null)
.cast<Node<T>>();
return _calculateNodesBounds(selectedNodes);
}