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<
Gets the current pan position of the viewport.T> , provided by the NodeFlowControllerAPI extensionno setter - currentZoom → double
-
Available on NodeFlowController<
Gets the current zoom level of the viewport.T> , provided by the NodeFlowControllerAPI extensionno 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<
Gets the bounding rectangle that encompasses all nodes in the graph.T> , provided by the NodeFlowControllerAPI extensionno 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<
Gets the bounding rectangle that encompasses all selected nodes in world coordinates.T> , provided by the NodeFlowControllerAPI extensionno 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<
Gets the viewport extent as a Rect in world coordinates.T> , provided by the NodeFlowControllerAPI extensionno setter - viewportScreenBounds → Rect
-
Available on NodeFlowController<
Gets the viewport extent as a Rect in screen coordinates.T> , provided by the NodeFlowControllerAPI extensionno setter
Methods
-
addAnnotation(
Annotation annotation) → void -
Available on NodeFlowController<
Adds an annotation to the graph.T> , provided by the NodeFlowControllerAPI extension -
addConnection(
Connection connection) → void -
Available on NodeFlowController<
Adds a connection between two ports.T> , provided by the NodeFlowControllerAPI extension -
addInputPort(
String nodeId, Port port) → void -
Available on NodeFlowController<
Adds an input port to an existing node.T> , provided by the NodeFlowControllerAPI extension -
addNode(
Node< T> node) → void -
Available on NodeFlowController<
Adds a new node to the graph.T> , provided by the NodeFlowControllerAPI extension -
addOutputPort(
String nodeId, Port port) → void -
Available on NodeFlowController<
Adds an output port to an existing node.T> , provided by the NodeFlowControllerAPI extension -
alignNodes(
List< String> nodeIds, NodeAlignment alignment) → void -
Available on NodeFlowController<
Aligns multiple nodes according to the specified alignment option.T> , provided by the NodeFlowControllerAPI extension -
arrangeNodesHierarchically(
) → void -
Available on NodeFlowController<
Arranges nodes hierarchically by type.T> , provided by the NodeFlowControllerAPI extension -
arrangeNodesInGrid(
{double spacing = 150.0}) → void -
Available on NodeFlowController<
Arranges all nodes in a grid layout.T> , provided by the NodeFlowControllerAPI extension -
bringNodeForward(
String nodeId) → void -
Available on NodeFlowController<
Moves a node one step forward in the z-order.T> , provided by the NodeFlowControllerAPI extension -
bringNodeToFront(
String nodeId) → void -
Available on NodeFlowController<
Brings a node to the front of the z-order (renders on top of all other nodes).T> , provided by the NodeFlowControllerAPI extension -
centerOnNode(
String nodeId) → void -
Available on NodeFlowController<
Centers the viewport on a specific node without changing the zoom level.T> , provided by the NodeFlowControllerAPI extension -
centerOnSelection(
) → void -
Available on NodeFlowController<
Centers the viewport on the center point of all selected nodes without changing zoom.T> , provided by the NodeFlowControllerAPI extension -
clearAnnotationSelection(
) → void -
Available on NodeFlowController<
Clears all annotation selections.T> , provided by the NodeFlowControllerAPI extension -
clearConnectionSelection(
) → void -
Available on NodeFlowController<
Clears all connection selections.T> , provided by the NodeFlowControllerAPI extension -
clearGraph(
) → void -
Available on NodeFlowController<
Clears the entire graph, removing all nodes, connections, annotations, and selections.T> , provided by the NodeFlowControllerAPI extension -
clearNodeSelection(
) → void -
Available on NodeFlowController<
Clears all node selections.T> , provided by the NodeFlowControllerAPI extension -
clearSelection(
) → void -
Available on NodeFlowController<
Clears all selections (nodes, connections, and annotations).T> , provided by the NodeFlowControllerAPI extension -
createConnection(
String sourceNodeId, String sourcePortId, String targetNodeId, String targetPortId) → void -
Available on NodeFlowController<
Creates a connection between two ports.T> , provided by the NodeFlowControllerAPI extension -
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<
Creates and adds a group annotation that visually groups multiple nodes.T> , provided by the NodeFlowControllerAPI extension -
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<
Creates and adds a marker annotation to the graph.T> , provided by the NodeFlowControllerAPI extension -
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<
Creates and adds a sticky note annotation to the graph.T> , provided by the NodeFlowControllerAPI extension -
deleteAllConnectionsForNode(
String nodeId) → void -
Available on NodeFlowController<
Deletes all connections associated with a node.T> , provided by the NodeFlowControllerAPI extension -
deleteNodes(
List< String> nodeIds) → void -
Available on NodeFlowController<
Deletes multiple nodes from the graph.T> , provided by the NodeFlowControllerAPI extension -
deleteSelectedAnnotations(
) → void -
Available on NodeFlowController<
Deletes all currently selected annotations.T> , provided by the NodeFlowControllerAPI extension -
detectCycles(
) → List< List< String> > -
Available on NodeFlowController<
Detects cycles in the graph using depth-first search.T> , provided by the NodeFlowControllerAPI extension -
dispose(
) → void - Disposes of the controller and releases resources.
-
distributeNodesHorizontally(
List< String> nodeIds) → void -
Available on NodeFlowController<
Distributes nodes evenly along the horizontal axis.T> , provided by the NodeFlowControllerAPI extension -
distributeNodesVertically(
List< String> nodeIds) → void -
Available on NodeFlowController<
Distributes nodes evenly along the vertical axis.T> , provided by the NodeFlowControllerAPI extension -
duplicateNode(
String nodeId) → void -
Available on NodeFlowController<
Creates a duplicate of a node and adds it to the graph.T> , provided by the NodeFlowControllerAPI extension -
exportGraph(
) → NodeGraph< T> -
Available on NodeFlowController<
Exports the current graph state including all nodes, connections, annotations, and viewport.T> , provided by the NodeFlowControllerAPI extension -
fitSelectedNodes(
) → void -
Available on NodeFlowController<
Adjusts the viewport to fit all selected nodes in the view with padding.T> , provided by the NodeFlowControllerAPI extension -
fitToView(
) → void -
Available on NodeFlowController<
Adjusts the viewport to fit all nodes in the view with padding.T> , provided by the NodeFlowControllerAPI extension -
getAnnotation(
String annotationId) → Annotation? -
Available on NodeFlowController<
Gets an annotation by its ID.T> , provided by the NodeFlowControllerAPI extension -
getConnectionsForNode(
String nodeId) → List< Connection> -
Available on NodeFlowController<
Gets all connections associated with a node.T> , provided by the NodeFlowControllerAPI extension -
getNode(
String nodeId) → Node< T> ? -
Available on NodeFlowController<
Gets a node by its ID.T> , provided by the NodeFlowControllerAPI extension -
getOrphanNodes(
) → List< Node< T> > -
Available on NodeFlowController<
Gets all nodes that have no connections.T> , provided by the NodeFlowControllerAPI extension -
hideAllAnnotations(
) → void -
Available on NodeFlowController<
Hides all annotations in the graph.T> , provided by the NodeFlowControllerAPI extension -
hitTestAnnotations(
Offset graphPosition) → Annotation? -
Available on NodeFlowController<
Hit test annotations at a specific position This is a delegating method for the editor's hit testingT> , provided by the NodeFlowControllerAPI extension -
hitTestConnections(
Offset graphPosition) → String? -
Available on NodeFlowController<
Tests if a point hits any connection.T> , provided by the NodeFlowControllerAPI extension -
invertSelection(
) → void -
Available on NodeFlowController<
Inverts the current node selection.T> , provided by the NodeFlowControllerAPI extension -
isAnnotationSelected(
String annotationId) → bool -
Available on NodeFlowController<
Checks if an annotation is currently selected.T> , provided by the NodeFlowControllerAPI extension -
isNodeSelected(
String nodeId) → bool -
Available on NodeFlowController<
Checks if a node is currently selected.T> , provided by the NodeFlowControllerAPI extension -
isPointVisible(
Offset worldPoint) → bool -
Available on NodeFlowController<
Checks if a world coordinate point is visible in the current viewport.T> , provided by the NodeFlowControllerAPI extension -
isRectVisible(
Rect worldRect) → bool -
Available on NodeFlowController<
Checks if a world coordinate rectangle intersects with the viewport.T> , provided by the NodeFlowControllerAPI extension -
loadGraph(
NodeGraph< T> graph) → void -
Available on NodeFlowController<
Loads a complete graph into the controller.T> , provided by the NodeFlowControllerAPI extension -
moveNode(
String nodeId, Offset delta) → void -
Available on NodeFlowController<
Moves a node by the specified delta.T> , provided by the NodeFlowControllerAPI extension -
moveSelectedNodes(
Offset delta) → void -
Available on NodeFlowController<
Moves all selected nodes by the specified delta.T> , provided by the NodeFlowControllerAPI extension -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
panBy(
Offset delta) → void -
Available on NodeFlowController<
Pans the viewport by a delta offset.T> , provided by the NodeFlowControllerAPI extension -
panToPosition(
Offset graphPosition) → void -
Available on NodeFlowController<
Pans the viewport to center on the specified graph position.T> , provided by the MinimapControllerExtension extension -
removeAnnotation(
String annotationId) → void -
Available on NodeFlowController<
Removes an annotation from the graph.T> , provided by the NodeFlowControllerAPI extension -
removeConnection(
String connectionId) → void -
Available on NodeFlowController<
Removes a connection from the graph.T> , provided by the NodeFlowControllerAPI extension -
removeNode(
String nodeId) → void -
Available on NodeFlowController<
Removes a node from the graph along with all its connections.T> , provided by the NodeFlowControllerAPI extension -
removePort(
String nodeId, String portId) → void -
Available on NodeFlowController<
Removes a port from a node and all connections involving that port.T> , provided by the NodeFlowControllerAPI extension -
resetViewport(
) → void -
Available on NodeFlowController<
Resets the viewport to zoom 1.0 and centers on all nodes in the graph.T> , provided by the NodeFlowControllerAPI extension -
screenToWorld(
Offset screenPoint) → Offset -
Available on NodeFlowController<
Converts a screen coordinate point to world coordinates.T> , provided by the NodeFlowControllerAPI extension -
selectAllConnections(
) → void -
Available on NodeFlowController<
Selects all connections in the graph.T> , provided by the NodeFlowControllerAPI extension -
selectAllNodes(
) → void -
Available on NodeFlowController<
Selects all nodes in the graph.T> , provided by the NodeFlowControllerAPI extension -
selectAnnotation(
String annotationId, {bool toggle = false}) → void -
Available on NodeFlowController<
Selects an annotation in the graph.T> , provided by the NodeFlowControllerAPI extension -
selectConnection(
String connectionId, {bool toggle = false}) → void -
Available on NodeFlowController<
Selects a connection in the graph.T> , provided by the NodeFlowControllerAPI extension -
selectNode(
String nodeId, {bool toggle = false}) → void -
Available on NodeFlowController<
Selects a node in the graph.T> , provided by the NodeFlowControllerAPI extension -
selectNodes(
List< String> nodeIds, {bool toggle = false}) → void -
Available on NodeFlowController<
Selects multiple nodes in the graph.T> , provided by the NodeFlowControllerAPI extension -
selectNodesByType(
String type) → void -
Available on NodeFlowController<
Selects all nodes of a specific type.T> , provided by the NodeFlowControllerAPI extension -
selectSpecificNodes(
List< String> nodeIds) → void -
Available on NodeFlowController<
Selects only the specified nodes, clearing any existing selection.T> , provided by the NodeFlowControllerAPI extension -
sendNodeBackward(
String nodeId) → void -
Available on NodeFlowController<
Moves a node one step backward in the z-order.T> , provided by the NodeFlowControllerAPI extension -
sendNodeToBack(
String nodeId) → void -
Available on NodeFlowController<
Sends a node to the back of the z-order (renders behind all other nodes).T> , provided by the NodeFlowControllerAPI extension -
setCallbacks(
NodeFlowCallbacks< T> callbacks) → void -
Available on NodeFlowController<
Update the callbacks that the controller will use This is called internally by the editor widget onlyT> , provided by the NodeFlowControllerAPI extension -
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<
Sets the input and/or output ports of a node.T> , provided by the NodeFlowControllerAPI extension -
setNodePosition(
String nodeId, Offset position) → void -
Available on NodeFlowController<
Sets a node's position to an absolute position.T> , provided by the NodeFlowControllerAPI extension -
setNodeShapeBuilder(
NodeShape? builder(Node< T> node)?) → void - Sets the node shape builder function.
-
setNodeSize(
String nodeId, Size size) → void -
Available on NodeFlowController<
Sets the size of a node.T> , provided by the NodeFlowControllerAPI extension -
setScreenSize(
Size size) → void -
Available on NodeFlowController<
Sets the screen size used for viewport calculations.T> , provided by the NodeFlowControllerAPI extension -
setTheme(
NodeFlowTheme theme) → void -
Available on NodeFlowController<
Set the theme and update the connection painter This is called internally by the editor widget onlyT> , provided by the NodeFlowControllerAPI extension -
setViewport(
GraphViewport viewport) → void -
Available on NodeFlowController<
Sets the viewport to a specific position and zoom level.T> , provided by the NodeFlowControllerAPI extension -
showAllAnnotations(
) → void -
Available on NodeFlowController<
Shows all annotations in the graph.T> , provided by the NodeFlowControllerAPI extension -
showShortcutsDialog(
BuildContext context) → void -
Available on NodeFlowController<
Shows the keyboard shortcuts dialog.T> , provided by the NodeFlowControllerAPI extension -
toString(
) → String -
A string representation of this object.
inherited
-
worldToScreen(
Offset worldPoint) → Offset -
Available on NodeFlowController<
Converts a world coordinate point to screen coordinates.T> , provided by the NodeFlowControllerAPI extension -
zoomBy(
double delta) → void -
Available on NodeFlowController<
Zoom the viewport by a delta value while maintaining the viewport center as the focal point.T> , provided by the NodeFlowControllerAPI extension -
zoomTo(
double zoom) → void -
Available on NodeFlowController<
Sets the viewport zoom to a specific value.T> , provided by the NodeFlowControllerAPI extension
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited