AnnotationLayer<T> class

A rendering layer for annotations in the node flow editor.

This widget serves as a rendering layer that displays annotations on the canvas. It automatically:

  • Observes annotation changes via MobX for reactive updates
  • Sorts annotations by z-index for proper layering
  • Applies filtering to show specific annotation types
  • Handles selection and highlight visual feedback
  • Wires gesture callbacks to individual AnnotationWidget instances
  • Uses RepaintBoundary for optimized rendering

Layer Architecture

The node flow editor typically uses two annotation layers:

  1. Background layer: Renders GroupAnnotations behind nodes
  2. Foreground layer: Renders sticky notes and markers above connections

Example Usage

// Background layer for groups
AnnotationLayer<MyNodeData>.background(controller)

// Foreground layer for stickies and markers
AnnotationLayer<MyNodeData>.foreground(controller)

// Custom filtered layer
AnnotationLayer<MyNodeData>(
  controller: controller,
  filter: (annotation) => annotation is StickyAnnotation,
)

See also:

Inheritance
Available extensions

Constructors

AnnotationLayer({Key? key, required NodeFlowController<T> controller, bool filter(Annotation)?, void onAnnotationTap(Annotation annotation)?, void onAnnotationDoubleTap(Annotation annotation)?, void onAnnotationContextMenu(Annotation annotation, Offset globalPosition)?, void onAnnotationMouseEnter(Annotation annotation)?, void onAnnotationMouseLeave(Annotation annotation)?})
Creates an annotation layer.
const

Properties

controller NodeFlowController<T>
The node flow controller managing the annotations.
final
filter bool Function(Annotation)?
Optional filter to determine which annotations to render.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onAnnotationContextMenu → void Function(Annotation annotation, Offset globalPosition)?
Callback invoked when an annotation is right-clicked (context menu).
final
onAnnotationDoubleTap → void Function(Annotation annotation)?
Callback invoked when an annotation is double-tapped.
final
onAnnotationMouseEnter → void Function(Annotation annotation)?
Callback invoked when mouse enters an annotation.
final
onAnnotationMouseLeave → void Function(Annotation annotation)?
Callback invoked when mouse leaves an annotation.
final
onAnnotationTap → void Function(Annotation annotation)?
Callback invoked when an annotation is tapped.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited
withAnnotationLayer(NodeFlowController<T> controller) Widget

Available on Widget, provided by the AnnotationLayerSupport extension

Wraps this widget with an annotation layer.

Operators

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

Static Methods

background<T>(NodeFlowController<T> controller, {void onAnnotationTap(Annotation annotation)?, void onAnnotationDoubleTap(Annotation annotation)?, void onAnnotationContextMenu(Annotation annotation, Offset globalPosition)?, void onAnnotationMouseEnter(Annotation annotation)?, void onAnnotationMouseLeave(Annotation annotation)?}) AnnotationLayer<T>
Creates a background annotation layer that renders only groups.
foreground<T>(NodeFlowController<T> controller, {void onAnnotationTap(Annotation annotation)?, void onAnnotationDoubleTap(Annotation annotation)?, void onAnnotationContextMenu(Annotation annotation, Offset globalPosition)?, void onAnnotationMouseEnter(Annotation annotation)?, void onAnnotationMouseLeave(Annotation annotation)?}) AnnotationLayer<T>
Creates a foreground annotation layer that renders everything except groups.