AnnotationDragContext class
Context provided to annotations during drag and node lifecycle operations.
This context allows annotations to interact with nodes during drag, enabling behaviors like moving contained nodes when a group is dragged, or refitting bounds when member nodes are deleted.
Example Usage in a Custom Annotation
class MyGroupAnnotation extends Annotation {
Set<String>? _containedNodeIds;
@override
void onDragStart(AnnotationDragContext context) {
// Capture nodes inside this annotation at drag start
_containedNodeIds = context.findNodesInBounds(bounds);
}
@override
void onDragMove(Offset delta, AnnotationDragContext context) {
// Move the contained nodes along with this annotation
if (_containedNodeIds != null && _containedNodeIds!.isNotEmpty) {
context.moveNodes(_containedNodeIds!, delta);
}
}
@override
void onDragEnd() {
_containedNodeIds = null;
}
}
Constructors
Properties
-
findNodesInBounds
→ Set<
String> Function(Rect bounds) -
Finds all node IDs whose bounds are completely contained within the given rect.
final
- getNode → Node? 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
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