NodeDragContext<T> class

Context provided to nodes during drag and lifecycle operations.

This context allows nodes (including annotations that extend Node) to interact with other nodes during drag, enabling behaviors like moving contained nodes when a group is dragged, or refitting bounds when member nodes are deleted.

Example Usage

class MyGroupNode extends Node<GroupData> {
  Set<String>? _containedNodeIds;

  @override
  void onDragStart(NodeDragContext context) {
    // Capture nodes inside this group at drag start
    _containedNodeIds = context.findNodesInBounds(getBounds());
  }

  @override
  void onDragMove(Offset delta, NodeDragContext context) {
    // Move the contained nodes along with this group
    if (_containedNodeIds != null && _containedNodeIds!.isNotEmpty) {
      context.moveNodes(_containedNodeIds!, delta);
    }
  }

  @override
  void onDragEnd() {
    _containedNodeIds = null;
  }
}

Constructors

NodeDragContext({required void moveNodes(Set<String> nodeIds, Offset delta), required Set<String> findNodesInBounds(Rect bounds), required Node<T>? getNode(String nodeId), bool shouldSkipUpdates()?})
const

Properties

findNodesInBounds Set<String> Function(Rect bounds)
Finds all node IDs whose bounds are completely contained within the given rect.
final
getNode Node<T>? Function(String nodeId)
Looks up a node by ID.
final
hashCode int
The hash code for this object.
no setterinherited
moveNodes → void Function(Set<String> nodeIds, Offset delta)
Moves a set of nodes by the given delta.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shouldSkipUpdates bool Function()?
Returns true if updates should be skipped.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited