vyuh_node_flow library

A flexible, high-performance node-based flow editor for Flutter.

vyuh_node_flow is a comprehensive Flutter package for building interactive node-based editors, visual programming interfaces, workflow editors, diagrams, and data processing pipelines. Inspired by React Flow, it provides a rich set of features for creating sophisticated visual programming experiences.

Features

  • Interactive Node Editor: Drag, resize, and connect nodes with an intuitive interface
  • Flexible Connections: Support for multiple connection styles (bezier, straight, step) with customizable endpoints and labels
  • Rich Theming: Comprehensive theming system for nodes, ports, and connections
  • Viewport Controls: Pan, zoom, and minimap support for navigating large graphs
  • State Management: Built on MobX for reactive, observable state management
  • Grouping & Comments: GroupNode for visual grouping, CommentNode for floating text comments
  • Validation: Built-in connection validation and custom validation support
  • Keyboard Shortcuts: Extensive keyboard shortcuts for productivity
  • Serialization: JSON serialization support for saving and loading graphs

Core Components

Graph Components

Nodes

  • Node: The core node model representing graph nodes
  • GroupNode: Special node for visually grouping other nodes
  • CommentNode: Special node for floating text comments
  • NodeWidget: Base widget for rendering nodes
  • NodeData: Custom data interface for node content
  • InteractionState: Tracks node interaction states (hover, selected, etc.)

Connections

  • Connection: Model representing edges between nodes
  • ConnectionEndpoint: Defines connection start and end points
  • ConnectionStyleBase: Base class for connection rendering styles
  • ConnectionTheme: Theming for connection appearance
  • ConnectionValidation: Interface for validating connections

Ports

  • Port: Model for node input/output ports
  • PortTheme: Theming for port appearance

Spatial Index

  • SpatialQueries: Read-only interface for spatial queries and hit testing

Basic Usage

import 'package:vyuh_node_flow/vyuh_node_flow.dart';
import 'package:flutter/material.dart';

class MyNodeEditor extends StatefulWidget {
  @override
  State<MyNodeEditor> createState() => _MyNodeEditorState();
}

class _MyNodeEditorState extends State<MyNodeEditor> {
  late NodeFlowController controller;

  @override
  void initState() {
    super.initState();
    controller = NodeFlowController(
      graph: Graph(
        nodes: [
          Node(id: 'node-1', position: Offset(100, 100)),
          Node(id: 'node-2', position: Offset(300, 100)),
        ],
        connections: [
          Connection(
            id: 'conn-1',
            source: ConnectionEndpoint(nodeId: 'node-1'),
            target: ConnectionEndpoint(nodeId: 'node-2'),
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: NodeFlowEditor(
        controller: controller,
        config: NodeFlowConfig(),
      ),
    );
  }

  @override
  void dispose() {
    controller.dispose();
    super.dispose();
  }
}

State Management

This library uses MobX for reactive state management. All core models are observable, enabling automatic UI updates when the graph state changes.

Classes

ArrowParticle
An arrow-shaped particle painter.
AutoPanExtension
Extension for managing autopan behavior during drag operations.
AutopanZoneDebugLayer<T>
Debug layer that visualizes the autopan edge zones.
BatchEnded
Marks the end of a batch operation.
BatchStarted
Marks the start of a batch operation.
CharacterParticle
A character/emoji particle painter.
CircleParticle
A circular particle painter.
CircleShape
A circular node shape.
CommentNode<T>
A comment/sticky note node that can be placed anywhere on the canvas.
Connection<C>
Represents a visual connection between two ports on different nodes in a node flow diagram.
ConnectionAdded
Emitted when a connection is added to the graph.
ConnectionCompleteContext<T>
Context provided when attempting to complete a connection.
ConnectionDragEnded
Emitted when connection drag ends (connected or cancelled).
ConnectionDragStarted
Emitted when connection creation begins (dragging from a port).
ConnectionEffect
Abstract interface for connection animation effects.
ConnectionEffects
Built-in connection animation effects
ConnectionEndPoint
Defines the visual marker at the start or end of a connection.
ConnectionEvents<T, C>
Events related to connection interactions.
ConnectionHoverChanged
Emitted when hover state changes on a connection.
ConnectionLabel
Represents a label that can be positioned on a connection path.
ConnectionPathParameters
Parameters for connection path creation
ConnectionRemoved
Emitted when a connection is removed from the graph.
ConnectionStartContext<T>
Context provided when starting a connection from a port.
ConnectionStyle
Abstract base class for connection styles.
ConnectionStyles
Built-in connection styles
ConnectionTheme
Defines the visual styling and behavior of connections in the node flow.
ConnectionValidationResult
Represents the result of a connection validation check.
CursorTheme
Theme configuration for mouse cursors in the node flow editor.
DebugExtension
Extension for managing debug visualization overlays.
DebugLayersStack<T>
Stack of graph-coordinate debug visualization layers.
DebugTheme
Theme configuration for debug visualizations.
DefaultNodeFlowActions<T>
Factory for creating default node flow actions.
DetailVisibility
Configuration that defines which visual elements should be rendered at a given Level of Detail.
DiamondShape
A diamond (rhombus) node shape.
EditablePathConnectionStyle
Abstract base class for connection styles that support interactive editing of connection paths through control points.
EditableSmoothStepConnectionStyle
An editable connection style that creates smooth step paths with rounded corners.
ExtensionRegistry
Registry that manages extension instances.
FlowError
Error information
FlowingDashEffect
An animation effect that creates a flowing dash pattern along the connection.
GradientFlowEffect
An animation effect that creates a flowing gradient along the connection.
GraphCleared
Emitted when the graph is cleared.
GraphEvent
Base class for all graph events emitted by NodeFlowController.
GraphLoaded
Emitted when a graph is loaded (replacing current content).
GraphViewport
Represents the viewport transformation for a node flow graph.
GridStyle
Abstract base class for all grid styles.
GridStyles
Provides static constants for different grid styles.
GridTheme
Theme configuration for the grid background.
GroupNode<T>
A group node that creates a region for containing other nodes.
HexagonShape
A hexagonal node shape.
HitTestResult
Result of a hit test operation.
LabelTheme
Defines the visual styling for connection labels.
LodExtension
Level of Detail (LOD) extension that provides reactive visibility settings based on the viewport zoom level.
LODLevelChanged
Emitted when the LOD visibility level changes.
MarkerShape
Abstract base class for marker shapes.
MarkerShapes
Predefined marker shape constants.
MinimapExtension
Minimap extension for managing minimap state and behavior.
MinimapPainter<T>
Custom painter for rendering the minimap visualization.
MinimapTheme
Theme configuration for the minimap visual appearance.
Node<T>
Represents a single node in the flow graph.
NodeAdded<T>
Emitted when a node is added to the graph.
NodeData
Interface that defines the contract for node data objects.
NodeDataChanged<T>
Emitted when a node's data changes.
NodeDragContext<T>
Context provided to nodes during drag and lifecycle operations.
NodeDragEnded
Emitted when a node drag operation ends.
NodeDragStarted
Emitted when a node drag operation starts.
NodeEvents<T>
Events related to node interactions
NodeFlowAction<T>
Base class for actions that can be triggered in the node flow editor.
NodeFlowActionDispatcher<T>
A Flutter Action that dispatches to NodeFlow actions based on intent actionId.
NodeFlowActionIntent<T>
An Intent representing a NodeFlow action to be executed.
NodeFlowConfig
Reactive configuration class for NodeFlow behavioral properties.
NodeFlowController<T, C>
High-performance controller for node flow state management.
NodeFlowEditor<T, C>
Node flow editor widget using MobX for reactive state management.
NodeFlowEvents<T, C>
Comprehensive event system for the NodeFlowEditor.
NodeFlowExtension
Interface for extensions that add behavior and state to the node flow editor.
NodeFlowKeyboardHandler<T>
Primary keyboard handler for NodeFlow using Flutter's Actions and Shortcuts system.
NodeFlowMinimap<T>
A minimap widget that provides an overview of the entire node flow graph.
NodeFlowScope<T>
An InheritedWidget that provides NodeFlowController to descendants.
NodeFlowShortcutManager<T>
Manages keyboard shortcuts and action execution.
NodeFlowTheme
Theme configuration for the node flow editor.
NodeFlowViewer<T, C>
A simplified viewer for node flow graphs.
NodeGraph<T, C>
Immutable data class for graph serialization/deserialization.
NodeGroupChanged<T>
Emitted when a node's group membership changes.
NodeHoverChanged
Emitted when hover state changes on a node.
NodeLockChanged<T>
Emitted when a node's lock state changes.
NodeMoved<T>
Emitted when a node's position changes.
NodeRemoved<T>
Emitted when a node is removed from the graph.
NodeResized<T>
Emitted when a node's size changes.
NodeShape
Defines the visual shape and appearance of a node in the flow editor.
NodeTheme
Theme configuration for node appearance and styling.
NodeVisibilityChanged<T>
Emitted when a node's visibility changes.
NodeWidget<T>
A widget that builds the visual content of a node.
NodeZIndexChanged<T>
Emitted when a node's z-index changes.
ParticleEffect
An animation effect that shows particles moving along the connection path.
ParticlePainter
Abstract interface for rendering particles in a ParticleEffect.
Particles
Built-in particle painters
Port
Represents a connection point on a node in the flow editor.
PortAnchor
Defines a port anchor point on a node shape.
PortEvents<T>
Events related to port interactions.
PortHoverChanged
Emitted when hover state changes on a port.
PortTheme
Theme configuration for port visual appearance.
PortWidget<T>
Widget for rendering a port on a node.
PulseEffect
An animation effect that creates a pulsing/glowing effect on the connection.
ResizeEnded
Emitted when a resize operation ends.
ResizerTheme
Theme configuration for resize handles used by resizable nodes.
ResizeStarted
Emitted when a resize operation starts.
SelectionChanged
Emitted when the selection changes.
SelectionState<T, C>
Represents the current selection state.
SelectionTheme
Theme configuration for the selection rectangle appearance.
SpatialIndexDebugLayer<T>
Debug layer that visualizes the spatial index grid.
SpatialIndexDebugPainter
Debug painter that visualizes the spatial index grid.
SpatialQueries<T, C>
Public interface for spatial index queries.
StatsExtension
Reactive graph statistics extension.
ViewportChanged
Emitted when the viewport changes (pan or zoom).
ViewportEvents
Events related to viewport/canvas interactions (pan, zoom, canvas taps)

Enums

DebugMode
Debug visualization mode for NodeFlow.
ElementType
The type of UI element for cursor resolution.
GroupBehavior
How a group determines its member nodes and sizing behavior.
HexagonOrientation
Defines the orientation of a hexagon shape.
HitTarget
Hit test target types for different UI elements.
MinimapPosition
Position options for minimap placement.
NodeAlignment
Alignment options for node alignment operations
NodeFlowBehavior
Defines how the node flow canvas behaves.
NodeRenderLayer
The rendering layer for a node.
PortPosition
Defines the position of a port on a node.
PortType
Defines the directionality of a port in a node-based flow editor.
ResizeHandle
Position of resize handles on a resizable element.
ShapeDirection
Orientation/direction for marker shapes.

Mixins

NodeFlowActionsMixin<T extends StatefulWidget>
A mixin that provides convenient methods for executing NodeFlow actions from within stateful widgets.

Extension Types

GraphOffset
Extension type representing a delta/movement in graph coordinate space.
GraphPosition
Extension type representing an absolute position in graph/world coordinate space.
GraphRect
Extension type representing a rectangle in graph/world coordinate space.
ScreenOffset
Extension type representing a delta/movement in screen coordinate space.
ScreenPosition
Extension type representing an absolute position in screen coordinate space.
ScreenRect
Extension type representing a rectangle in screen coordinate space.

Extensions

AutoPanExtensionAccess on NodeFlowController<T, dynamic>
Dart extension providing access to the autopan extension.
ConnectionApi on NodeFlowController<T, C>
Connection-related operations for NodeFlowController.
ConnectionEffectExtension on ConnectionEffect
Extension to add convenience methods to connection animation effect instances
ConnectionStyleExtension on ConnectionStyle
Extension to add conversion methods to connection style instances
CursorThemeExtension on CursorTheme
Extension on CursorTheme for deriving cursors from interaction state.
DebugExtensionAccess on NodeFlowController<T, dynamic>
Dart extension providing access to the debug extension.
DirtyTrackingExtension on NodeFlowController<T, C>
Dirty tracking and spatial index management for NodeFlowController.
EditorInitApi on NodeFlowController<T, C>
Editor initialization API for NodeFlowController.
GraphApi on NodeFlowController<T, C>
Graph-level operations for NodeFlowController.
GraphPositionOffsetExtension on GraphPosition
Extension methods for applying GraphOffset to GraphPosition.
GroupApi on NodeFlowController<T, C>
Group and node monitoring operations for NodeFlowController.
LodExtensionAccess on NodeFlowController<T, dynamic>
Dart extension providing convenient access to LOD functionality.
MinimapControllerExtension on NodeFlowController<T, dynamic>
Extension adding minimap navigation functionality to NodeFlowController.
MinimapExtensionAccess on NodeFlowController<T, dynamic>
Dart extension providing access to the minimap extension.
NodeApi on NodeFlowController<T, C>
Node-related operations for NodeFlowController.
NodeFlowControllerAPI on NodeFlowController<T, C>
Factory methods and drag operations for NodeFlowController.
NodePortGeometry on Node<T>
Extension providing port geometry calculations for nodes.
ParticlePainterExtension on ParticlePainter
Extension to add convenience methods to particle painter instances
PortPositionExtension on PortPosition
Extension on PortPosition providing centralized port geometry calculations.
ResizeApi on NodeFlowController<T, C>
Resize operations for NodeFlowController.
ScreenPositionOffsetExtension on ScreenPosition
Extension methods for applying ScreenOffset to ScreenPosition.
StatsExtensionAccess on NodeFlowController<T, dynamic>
Dart extension providing access to the stats extension.
ViewportApi on NodeFlowController<T, C>
Viewport operations for NodeFlowController.

Constants

defaultPortSize → const Size
Default port size used when no size is specified.
kGroupNodeDefaultPadding → const EdgeInsets
Default padding for group nodes.

Functions

defaultNodeFromJson<T>(Map<String, dynamic> json, T fromJsonT(Object? json)) Node<T>
Default factory for deserializing nodes with type routing.

Typedefs

BeforeDeleteCallback<T> = Future<bool> Function(T item)
Async callback that can veto a deletion operation.
ConnectionStyleBuilder<T, C> = ConnectionStyle? Function(Connection<C> connection, Node<T> sourceNode, Node<T> targetNode)
Builder function for dynamic connection style selection.
LabelBuilder = Widget Function(BuildContext context, Connection connection, ConnectionLabel label, Rect position, VoidCallback? onTap)
Builder function type for customizing connection label widgets.
NodeLookup = Node? Function(String nodeId)
Callback type for looking up nodes by ID.
NodeWidgetBuilder<T> = Widget Function(BuildContext context, Node<T> node)
Builder function for creating a node widget.
PortBuilder<T> = Widget Function(BuildContext context, Node<T> node, Port port)
Builds a custom port widget for a node.
PortWidgetBuilder<T> = Widget Function(BuildContext context, Node<T> node, Port port)
Builder function for creating a port widget.