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, connections, and annotations
  • Viewport Controls: Pan, zoom, and minimap support for navigating large graphs
  • State Management: Built on MobX for reactive, observable state management
  • Annotations Layer: Add custom annotations and overlays to your flow diagrams
  • 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
  • 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

Annotations

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

Annotation
Base annotation class that can be placed in the node flow
AnnotationController<T>
Controller for managing annotations in the node flow
AnnotationDependency
Represents a dependency relationship between an annotation and a node.
AnnotationLayer<T>
A rendering layer for annotations in the node flow editor.
AnnotationWidget
Framework widget that wraps custom annotations with automatic functionality.
ArrowParticle
An arrow-shaped particle painter.
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.
Connection
Represents a visual connection between two ports on different nodes in a node flow diagram.
ConnectionAnchor
Defines standard anchor positions along a connection path.
ConnectionAnimationEffect
Abstract interface for connection animation effects.
ConnectionCompleteContext<T>
Context provided when attempting to complete a connection.
ConnectionEndPoint
Defines the visual marker at the start or end of a connection.
ConnectionLabel
Represents a label that can be positioned on a connection path.
ConnectionPathCalculator
Utility class for creating connection paths from style definitions.
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
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.
DefaultNodeFlowActions<T>
Factory for creating default node flow actions.
DiamondShape
A diamond (rhombus) node shape.
EndpointPositionCalculator
Utility class for calculating endpoint marker and connection line positions.
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.
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.
GroupAnnotation
A group annotation that automatically surrounds and contains a set of nodes.
HexagonShape
A hexagonal node shape.
InteractionLayerPainter<T>
Painter for interactive elements (selection rectangle and temporary connection).
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.
MarkerAnnotation
A small visual indicator for workflow elements (BPMN-style markers).
MinimapPainter<T>
Custom painter for rendering the minimap visualization.
Node<T>
Represents a single node in the flow graph.
NodeData
Interface that defines the contract for node data objects.
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 properties
NodeFlowController<T>
High-performance controller for node flow state management.
NodeFlowEditor<T>
Node flow editor widget using MobX for reactive state management.
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 read-only viewer for node flow graphs.
NodeGraph<T>
Immutable data class for graph serialization/deserialization All state management is handled by NodeFlowController
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.
NodeWidget<T>
A unified node widget that handles positioning, rendering, and interactions.
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.
PathParameters
Parameters for connection path creation
Port
Represents a connection point on a node in the flow editor.
PortAnchor
Defines a port anchor point on a node shape.
PortShapeConverter
A JSON converter for PortShape class.
PortTheme
Theme configuration for port visual appearance.
PulseEffect
An animation effect that creates a pulsing/glowing effect on the connection.
ShortcutsViewerDialog
A comprehensive shortcuts viewer dialog that displays all available keyboard shortcuts organized by category.
SizeConverter
A JSON converter for Flutter's Size class.
StickyAnnotation
A sticky note annotation that can be placed anywhere on the canvas.
TemporaryConnection
Represents a temporary connection during a drag-and-drop operation.

Enums

AnnotationDependencyType
Defines how an annotation responds to changes in dependent nodes.
HexagonOrientation
Defines the orientation of a hexagon shape.
MarkerType
Predefined marker types for BPMN-style workflow annotations.
MinimapPosition
Position options for minimap placement
NodeAlignment
Alignment options for node alignment operations
PortPosition
Defines the position of a port on a node.
PortType
Defines the directionality of a port in a node-based flow editor.

Mixins

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

Extensions

AnnotationLayerSupport on Widget
Extension to add annotation layer support to widgets.
ConnectionStyleExtension on ConnectionStyle
Extension to add conversion methods to connection style instances
MinimapControllerExtension on NodeFlowController<T>
Extension adding minimap navigation functionality to NodeFlowController.
NodeFlowControllerAPI on NodeFlowController<T>
PortPositionExtension on PortPosition
Extension on PortPosition to convert to ShapeOrientation