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 annotations
- 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
- NodeFlowEditor: The main interactive editor widget
- NodeFlowViewer: A read-only viewer for displaying node graphs
- NodeFlowController: Controller for managing graph state and operations
- NodeFlowConfig: Configuration for editor behavior and appearance
- Viewport: Manages pan, zoom, and transformation of the canvas
- NodeFlowMinimap: Minimap widget for navigation
Nodes
- Node: The core node model representing graph nodes
- GroupNode: Special node for visually grouping other nodes
- CommentNode: Special node for floating text annotations
- 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 pointsConnectionStyleBase: Base class for connection rendering styles- ConnectionTheme: Theming for connection appearance
ConnectionValidation: Interface for validating connections
Ports
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
- AnnotationTheme
- Theme configuration for annotation visual appearance.
- ArrowParticle
- An arrow-shaped particle painter.
- AutoPanConfig
- Configuration for 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.
- ColorConverter
- A JSON converter for Flutter's Color class.
-
CommentNode<
T> - A comment/sticky note node that can be placed anywhere on the canvas.
- Connection
- 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.
- ConnectionAnchor
- Defines standard anchor positions along a connection path.
-
ConnectionCompleteContext<
T> - Context provided when attempting to complete a connection.
- 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> - Events related to connection interactions
- ConnectionLabel
- Represents a label that can be positioned on a connection path.
- ConnectionPainter
- ConnectionPathParameters
- Parameters for connection path creation
- ConnectionRemoved
- Emitted when a connection is removed from the graph.
-
ConnectionsCanvas<
T> - Custom painter for rendering all connections in the node flow canvas.
-
ConnectionStartContext<
T> - Context provided when starting a connection from a port.
- ConnectionStyle
- Abstract base class for connection styles.
- ConnectionStyleOverrides
- Defines style overrides for a connection at the widget level.
- 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.
- CubicSegment
- A cubic bezier curve segment.
- CursorTheme
- Theme configuration for mouse cursors in the node flow editor.
-
DebugLayersStack<
T> - Stack of graph-coordinate debug visualization layers.
- DebugTheme
- Theme configuration for debug visualization.
-
DefaultNodeFlowActions<
T> - Factory for creating default node flow actions.
- DiamondShape
- A diamond (rhombus) node shape.
- DragSession
- Abstract interface for a drag session.
- 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.
- ElementScope
- A unified interaction scope for draggable elements (nodes, annotations, ports).
- EndpointPositionCalculator
- Utility class for calculating endpoint marker and connection line positions.
- 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.
- GraphEvent
- Base class for all graph events emitted by NodeFlowController.
-
GraphSpatialIndex<
T> - Simplified, type-safe spatial index for graph elements.
- 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.
- InteractionState
- Contains all interaction-related state for the node flow editor.
- LabelCalculator
- Utility class for calculating connection label positions.
- LabelTheme
- Defines the visual styling for connection labels.
- MarkerShape
- Abstract base class for marker shapes.
- MarkerShapeConverter
- A JSON converter for MarkerShape class.
- MarkerShapes
- Predefined marker shape constants.
-
MinimapPainter<
T> - Custom painter for rendering the minimap visualization.
- MinimapTheme
- Theme configuration for the minimap overlay.
-
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.
-
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> - High-performance controller for node flow state management.
-
NodeFlowEditor<
T> - Node flow editor widget using MobX for reactive state management.
-
NodeFlowEvents<
T> - Comprehensive event system for the NodeFlowEditor
-
NodeFlowExtension<
T> - Interface for extensions that can observe and react to graph events.
-
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.
-
NodeFlowShortcutManager<
T> - Manages keyboard shortcuts and action execution.
- NodeFlowTheme
- Theme configuration for the node flow editor.
-
NodeFlowViewer<
T> - A simplified viewer for node flow graphs.
-
NodeGraph<
T> - Immutable data class for graph serialization/deserialization All state management is handled by NodeFlowController
-
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.
- NodeShapeClipper
- A custom clipper that clips content to a node shape.
- NodeShapePainter
- A custom painter that renders a node shape with background and border.
- NodeTheme
- Theme configuration for node appearance and styling.
-
NodeVisibilityChanged<
T> - Emitted when a node's visibility changes.
-
NodeWidget<
T> - A unified node widget that handles positioning, rendering, and interactions for both regular nodes and annotations.
-
NodeZIndexChanged<
T> - Emitted when a node's z-index changes.
- OffsetConverter
- A JSON converter for Flutter's Offset class.
- 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
- PathSegment
- Base class for path segment primitives.
- 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.
- 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.
- QuadraticSegment
- A quadratic bezier curve segment.
- RequiredSizeConverter
- A non-nullable JSON converter for Flutter's Size class.
- ResizerTheme
- Theme configuration for resize handles used by nodes and annotations.
- ResizerWidget
- A widget that wraps a child with resize handles and edge hit areas.
- SelectionChanged
- Emitted when the selection changes.
-
SelectionState<
T> - Represents the current selection state
- SelectionTheme
- Theme configuration for the selection rectangle appearance.
- ShortcutsViewerDialog
- A comprehensive shortcuts viewer dialog that displays all available keyboard shortcuts organized by category.
- SizeConverter
- A JSON converter for Flutter's Size class.
-
SpatialIndexDebugLayer<
T> - Debug layer that visualizes the spatial index grid.
- SpatialIndexDebugPainter
- Debug painter that visualizes the spatial index grid.
- StraightSegment
- A straight line segment from the current point to end.
- TemporaryConnection
- Represents a temporary connection during a drag-and-drop operation.
- UnboundedPositioned
- A Positioned widget that allows hit testing on its child outside its bounds.
- UnboundedRepaintBoundary
- A RepaintBoundary that allows hit testing on its child outside its bounds.
- UnboundedSizedBox
- A SizedBox that allows hit testing on children outside its bounds.
- UnboundedStack
- A Stack that allows hit testing on children positioned outside its bounds.
- ViewportChanged
- Emitted when the viewport changes (pan or zoom).
- ViewportEvents
- Events related to viewport/canvas interactions (pan, zoom, canvas taps)
- WaypointBuilder
- Builds waypoints for connection paths with node-aware routing.
Enums
- DebugMode
- Debug visualization mode for NodeFlow.
- DragSessionType
- Types of drag sessions that can be created.
- 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.
- LoopbackDirection
- Direction for routing around obstacles.
- 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
-
GroupableMixin<
T> - Mixin for nodes that can group/contain other nodes.
-
NodeFlowActionsMixin<
T extends StatefulWidget> - A mixin that provides convenient methods for executing NodeFlow actions from within stateful widgets.
-
ResizableMixin<
T> - Mixin providing resize functionality for nodes.
- ViewportAnimationMixin
- Mixin that provides viewport animation capabilities for NodeFlowEditor.
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
-
ConnectionApi
on NodeFlowController<
T> - 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.
-
DirtyTrackingExtension
on NodeFlowController<
T> - Private extension for dirty tracking and spatial index management.
-
GraphApi
on NodeFlowController<
T> - Graph-level operations for NodeFlowController.
- GraphPositionOffsetExtension on GraphPosition
- Extension methods for applying GraphOffset to GraphPosition.
-
MinimapControllerExtension
on NodeFlowController<
T> - Extension adding minimap navigation functionality to NodeFlowController.
-
NodeApi
on NodeFlowController<
T> - Node-related operations for NodeFlowController.
-
NodeFlowControllerAPI
on NodeFlowController<
T> - 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.
- ResizeHandleExtension on ResizeHandle
- Extension to add cursor and widget building capabilities to resize handles.
- ScreenPositionOffsetExtension on ScreenPosition
- Extension methods for applying ScreenOffset to ScreenPosition.
-
ViewportApi
on NodeFlowController<
T> - 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
- ConnectionStyleResolver = ConnectionStyleOverrides? Function(dynamic connection)
- Type definition for the connection style resolver callback.
- 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.
- OnResizeEnd = void Function()
- OnResizeStart = void Function(ResizeHandle handle)
- Callbacks for resize operations.
- OnResizeUpdate = void Function(Offset delta)
-
PortBuilder<
T> = Widget Function(BuildContext context, NodeFlowController< T> controller, Node<T> node, Port port, bool isOutput, bool isConnected, Rect nodeBounds) - Builder function type for customizing individual port widgets.
- ViewportSyncCallback = void Function(GraphViewport viewport)
- Callback type for syncing final viewport state after animation completes.