onDragStart method

  1. @override
void onDragStart(
  1. AnnotationDragContext context
)
override

Called when a drag operation starts on this annotation.

Override this method to perform setup when the user begins dragging this annotation. Use the context to capture state, such as which nodes are contained within a group annotation.

Example

Set<String>? _containedNodeIds;

@override
void onDragStart(AnnotationDragContext context) {
  _containedNodeIds = context.findNodesInBounds(bounds);
}

Implementation

@override
void onDragStart(AnnotationDragContext context) {
  // Capture nodes to move based on behavior
  _containedNodeIds = switch (behavior) {
    // Spatial containment - find nodes inside bounds
    GroupBehavior.bounds => context.findNodesInBounds(bounds),
    // Explicit membership - use the explicit node ID set
    GroupBehavior.explicit => Set.from(_nodeIds),
    // Parent-child link - use the explicit node ID set
    GroupBehavior.parent => Set.from(_nodeIds),
  };
}