NodeFlowController<T> class

High-performance controller for node flow state management.

This is the main controller for managing nodes, connections, annotations, viewport, and interactions in a node flow editor. It uses MobX for reactive state management.

Type parameter T is the data type stored in each node.

Example:

// Create a controller with custom configuration
final controller = NodeFlowController<MyData>(
  initialViewport: GraphViewport(x: 0, y: 0, zoom: 1.0),
  config: NodeFlowConfig.defaultConfig,
);
Available extensions

Constructors

NodeFlowController({GraphViewport? initialViewport, NodeFlowConfig? config})

Properties

annotations AnnotationController<T>
latefinal
callbacks NodeFlowCallbacks<T>
Gets the current callback configuration.
no setter
canvasFocusNode FocusNode
The focus node for the canvas.
no setter
config NodeFlowConfig
Gets the controller's configuration settings.
no setter
connectionPainter ConnectionPainter
Gets the connection painter used for rendering and hit-testing connections.
no setter
connections List<Connection>
Gets all connections in the graph.
no setter
currentCursor MouseCursor
Gets the current mouse cursor style (package-private).
no setter
currentPan Offset

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Gets the current pan position of the viewport.
no setter
currentZoom double

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Gets the current zoom level of the viewport.
no setter
draggedNodeId String?
Gets the ID of the node currently being dragged, if any (package-private).
no setter
enableNodeDeletion bool
Whether node deletion via keyboard shortcuts is enabled.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasSelection bool
Checks if there is any active selection (nodes, connections, or annotations).
no setter
interaction InteractionState
final
isConnecting bool
Checks if a connection is currently being created (package-private).
no setter
isDrawingSelection bool
Checks if a selection rectangle is being drawn (package-private).
no setter
lastPointerPosition Offset?
Gets the last known pointer position (package-private).
no setter
nodes Map<String, Node<T>>
Gets all nodes in the graph as a map (package-private).
no setter
nodesBounds Rect

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Gets the bounding rectangle that encompasses all nodes in the graph.
no setter
nodeShapeBuilder NodeShape? Function(Node<T> node)?
Gets the node shape builder function.
no setter
panEnabled bool
Checks if viewport panning is currently enabled (package-private).
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
screenSize Size
Gets the current screen/canvas size (package-private).
no setter
selectedConnectionIds Set<String>
Gets the IDs of all currently selected connections (package-private).
no setter
selectedNodeIds Set<String>
Gets the IDs of all currently selected nodes.
no setter
selectedNodesBounds Rect?

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Gets the bounding rectangle that encompasses all selected nodes in world coordinates.
no setter
selectionRectangle Rect?
Gets the current selection rectangle being drawn (package-private).
no setter
selectionStartPoint Offset?
Gets the starting point of the selection rectangle (package-private).
no setter
shortcuts NodeFlowShortcutManager<T>
latefinal
sortedNodes List<Node<T>>
Gets nodes sorted by z-index (package-private).
no setter
temporaryConnection TemporaryConnection?
Gets the temporary connection being created, if any (package-private).
no setter
theme NodeFlowTheme?
Gets the current theme configuration.
no setter
viewport GraphViewport
Gets the current viewport state (position and zoom).
no setter
viewportExtent Rect

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Gets the viewport extent as a Rect in world coordinates.
no setter
viewportScreenBounds Rect

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Gets the viewport extent as a Rect in screen coordinates.
no setter

Methods

addAnnotation(Annotation annotation) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Adds an annotation to the graph.
addConnection(Connection connection) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Adds a connection between two ports.
addInputPort(String nodeId, Port port) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Adds an input port to an existing node.
addNode(Node<T> node) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Adds a new node to the graph.
addOutputPort(String nodeId, Port port) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Adds an output port to an existing node.
alignNodes(List<String> nodeIds, NodeAlignment alignment) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Aligns multiple nodes according to the specified alignment option.
arrangeNodesHierarchically() → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Arranges nodes hierarchically by type.
arrangeNodesInGrid({double spacing = 150.0}) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Arranges all nodes in a grid layout.
bringNodeForward(String nodeId) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Moves a node one step forward in the z-order.
bringNodeToFront(String nodeId) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Brings a node to the front of the z-order (renders on top of all other nodes).
centerOnNode(String nodeId) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Centers the viewport on a specific node without changing the zoom level.
centerOnSelection() → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Centers the viewport on the center point of all selected nodes without changing zoom.
clearAnnotationSelection() → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Clears all annotation selections.
clearConnectionSelection() → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Clears all connection selections.
clearGraph() → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Clears the entire graph, removing all nodes, connections, annotations, and selections.
clearNodeSelection() → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Clears all node selections.
clearSelection() → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Clears all selections (nodes, connections, and annotations).
createConnection(String sourceNodeId, String sourcePortId, String targetNodeId, String targetPortId) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Creates a connection between two ports.
createGroupAnnotation({required String title, required Set<String> nodeIds, String? id, EdgeInsets padding = const EdgeInsets.all(20.0), Color color = const Color(0xFF2196F3)}) GroupAnnotation

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Creates and adds a group annotation that visually groups multiple nodes.
createMarker({required Offset position, MarkerType markerType = MarkerType.info, String? id, double size = 24.0, Color color = const Color(0xFFF44336), String? tooltip, Offset offset = Offset.zero}) MarkerAnnotation

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Creates and adds a marker annotation to the graph.
createStickyNote({required Offset position, required String text, String? id, double width = 200.0, double height = 100.0, Color color = const Color(0xFFFFF59D), Offset offset = Offset.zero}) StickyAnnotation

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Creates and adds a sticky note annotation to the graph.
deleteAllConnectionsForNode(String nodeId) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Deletes all connections associated with a node.
deleteNodes(List<String> nodeIds) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Deletes multiple nodes from the graph.
deleteSelectedAnnotations() → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Deletes all currently selected annotations.
detectCycles() List<List<String>>

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Detects cycles in the graph using depth-first search.
dispose() → void
Disposes of the controller and releases resources.
distributeNodesHorizontally(List<String> nodeIds) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Distributes nodes evenly along the horizontal axis.
distributeNodesVertically(List<String> nodeIds) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Distributes nodes evenly along the vertical axis.
duplicateNode(String nodeId) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Creates a duplicate of a node and adds it to the graph.
exportGraph() NodeGraph<T>

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Exports the current graph state including all nodes, connections, annotations, and viewport.
fitSelectedNodes() → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Adjusts the viewport to fit all selected nodes in the view with padding.
fitToView() → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Adjusts the viewport to fit all nodes in the view with padding.
getAnnotation(String annotationId) Annotation?

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Gets an annotation by its ID.
getConnectionsForNode(String nodeId) List<Connection>

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Gets all connections associated with a node.
getNode(String nodeId) Node<T>?

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Gets a node by its ID.
getOrphanNodes() List<Node<T>>

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Gets all nodes that have no connections.
hideAllAnnotations() → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Hides all annotations in the graph.
hitTestAnnotations(Offset graphPosition) Annotation?

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Hit test annotations at a specific position This is a delegating method for the editor's hit testing
hitTestConnections(Offset graphPosition) String?

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Tests if a point hits any connection.
invertSelection() → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Inverts the current node selection.
isAnnotationSelected(String annotationId) bool

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Checks if an annotation is currently selected.
isNodeSelected(String nodeId) bool

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Checks if a node is currently selected.
isPointVisible(Offset worldPoint) bool

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Checks if a world coordinate point is visible in the current viewport.
isRectVisible(Rect worldRect) bool

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Checks if a world coordinate rectangle intersects with the viewport.
loadGraph(NodeGraph<T> graph) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Loads a complete graph into the controller.
moveNode(String nodeId, Offset delta) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Moves a node by the specified delta.
moveSelectedNodes(Offset delta) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Moves all selected nodes by the specified delta.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
panBy(Offset delta) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Pans the viewport by a delta offset.
panToPosition(Offset graphPosition) → void

Available on NodeFlowController<T>, provided by the MinimapControllerExtension extension

Pans the viewport to center on the specified graph position.
removeAnnotation(String annotationId) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Removes an annotation from the graph.
removeConnection(String connectionId) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Removes a connection from the graph.
removeNode(String nodeId) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Removes a node from the graph along with all its connections.
removePort(String nodeId, String portId) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Removes a port from a node and all connections involving that port.
resetViewport() → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Resets the viewport to zoom 1.0 and centers on all nodes in the graph.
screenToWorld(Offset screenPoint) Offset

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Converts a screen coordinate point to world coordinates.
selectAllConnections() → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Selects all connections in the graph.
selectAllNodes() → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Selects all nodes in the graph.
selectAnnotation(String annotationId, {bool toggle = false}) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Selects an annotation in the graph.
selectConnection(String connectionId, {bool toggle = false}) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Selects a connection in the graph.
selectNode(String nodeId, {bool toggle = false}) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Selects a node in the graph.
selectNodes(List<String> nodeIds, {bool toggle = false}) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Selects multiple nodes in the graph.
selectNodesByType(String type) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Selects all nodes of a specific type.
selectSpecificNodes(List<String> nodeIds) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Selects only the specified nodes, clearing any existing selection.
sendNodeBackward(String nodeId) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Moves a node one step backward in the z-order.
sendNodeToBack(String nodeId) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Sends a node to the back of the z-order (renders behind all other nodes).
setCallbacks(NodeFlowCallbacks<T> callbacks) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Update the callbacks that the controller will use This is called internally by the editor widget only
setNodeDeletion(bool value) → void
Sets whether node deletion via keyboard shortcuts is enabled.
setNodePorts(String nodeId, {List<Port>? inputPorts, List<Port>? outputPorts}) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Sets the input and/or output ports of a node.
setNodePosition(String nodeId, Offset position) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Sets a node's position to an absolute position.
setNodeShapeBuilder(NodeShape? builder(Node<T> node)?) → void
Sets the node shape builder function.
setNodeSize(String nodeId, Size size) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Sets the size of a node.
setScreenSize(Size size) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Sets the screen size used for viewport calculations.
setTheme(NodeFlowTheme theme) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Set the theme and update the connection painter This is called internally by the editor widget only
setViewport(GraphViewport viewport) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Sets the viewport to a specific position and zoom level.
showAllAnnotations() → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Shows all annotations in the graph.
showShortcutsDialog(BuildContext context) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Shows the keyboard shortcuts dialog.
toString() String
A string representation of this object.
inherited
worldToScreen(Offset worldPoint) Offset

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Converts a world coordinate point to screen coordinates.
zoomBy(double delta) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Zoom the viewport by a delta value while maintaining the viewport center as the focal point.
zoomTo(double zoom) → void

Available on NodeFlowController<T>, provided by the NodeFlowControllerAPI extension

Sets the viewport zoom to a specific value.

Operators

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