@@ -23,6 +23,59 @@ Experience Vyuh Node Flow in action! The live demo showcases all key features,
2323including node creation, drag-and-drop connections, custom theming, annotations,
2424minimap, and more.
2525
26+ ## Table of Contents
27+
28+ - [ Key Features] ( #-key-features )
29+ - [ Screenshots] ( #screenshots )
30+ - [ Installation] ( #installation )
31+ - [ Quick Start] ( #-quick-start )
32+ - [ Core Concepts] ( #core-concepts )
33+ - [ The Controller] ( #the-controller )
34+ - [ Theming] ( #theming )
35+ - [ Using Built-in Themes] ( #using-built-in-themes )
36+ - [ Creating Custom Themes] ( #creating-custom-themes )
37+ - [ Grid Styles] ( #grid-styles )
38+ - [ Available Grid Styles] ( #available-grid-styles )
39+ - [ Customizing Grid Appearance] ( #customizing-grid-appearance )
40+ - [ Building Nodes] ( #building-nodes )
41+ - [ Basic Node Widget] ( #basic-node-widget )
42+ - [ Custom Node Content] ( #custom-node-content )
43+ - [ Using Node Container Builder] ( #using-node-container-builder )
44+ - [ Node Types and Data] ( #node-types-and-data )
45+ - [ Working with Ports] ( #working-with-ports )
46+ - [ Port Basics] ( #port-basics )
47+ - [ Port Positions and Offsets] ( #port-positions-and-offsets )
48+ - [ Port Shapes] ( #port-shapes )
49+ - [ Multiple Connections] ( #multiple-connections )
50+ - [ Dynamic Ports] ( #dynamic-ports )
51+ - [ Connections] ( #connections )
52+ - [ Creating Connections] ( #creating-connections )
53+ - [ Connection Validation] ( #connection-validation )
54+ - [ Connection Styles] ( #connection-styles )
55+ - [ Connection Animation Effects] ( #connection-animation-effects )
56+ - [ Connection Endpoints] ( #connection-endpoints )
57+ - [ Connection Labels] ( #connection-labels )
58+ - [ Annotations] ( #annotations )
59+ - [ Built-in Annotation Types] ( #built-in-annotation-types )
60+ - [ Custom Annotations] ( #custom-annotations )
61+ - [ Following Nodes] ( #following-nodes )
62+ - [ Interactive Features] ( #interactive-features )
63+ - [ Editor Callbacks] ( #editor-callbacks )
64+ - [ Keyboard Shortcuts] ( #keyboard-shortcuts )
65+ - [ Feature Toggles] ( #feature-toggles )
66+ - [ Minimap] ( #minimap )
67+ - [ Read-Only Viewer] ( #read-only-viewer )
68+ - [ Serialization] ( #serialization )
69+ - [ Save and Load Graphs] ( #save-and-load-graphs )
70+ - [ Load from URL] ( #load-from-url )
71+ - [ Advanced Configuration] ( #️-advanced-configuration )
72+ - [ Grid Snapping] ( #grid-snapping )
73+ - [ Auto-Panning] ( #auto-panning )
74+ - [ Zoom Limits] ( #zoom-limits )
75+ - [ Complete Examples] ( #complete-examples )
76+ - [ API Reference] ( #-api-reference )
77+ - [ Tips and Best Practices] ( #-tips-and-best-practices )
78+
2679## ✨ Key Features
2780
2881- ** High Performance** - Reactive, optimized rendering for smooth interactions
@@ -315,8 +368,105 @@ controller.setTheme(customTheme);
315368
316369</details >
317370
318- > [ !NOTE] Grid styles available: ` GridStyle.dots ` , ` GridStyle.lines ` ,
319- > ` GridStyle.hierarchical ` , ` GridStyle.none `
371+ > [ !NOTE] Grid styles available: ` GridStyles.dots ` , ` GridStyles.lines ` ,
372+ > ` GridStyles.cross ` , ` GridStyles.hierarchical ` , ` GridStyles.none `
373+
374+ ---
375+
376+ ## Grid Styles
377+
378+ Vyuh Node Flow offers multiple grid style options to customize the background
379+ pattern of your flow editor canvas.
380+
381+ ### Available Grid Styles
382+
383+ <details >
384+ <summary ><strong >Lines Grid Style</strong ></summary >
385+
386+ The most common grid style with evenly spaced vertical and horizontal lines,
387+ providing clear visual reference.
388+
389+ ``` dart
390+ final theme = NodeFlowTheme.light.copyWith(
391+ gridStyle: GridStyles.lines,
392+ );
393+ ```
394+
395+ </details >
396+
397+ <details >
398+ <summary ><strong >Dots Grid Style</strong ></summary >
399+
400+ A more subtle alternative with dots at grid intersections, reducing visual
401+ clutter while maintaining reference points.
402+
403+ ``` dart
404+ final theme = NodeFlowTheme.light.copyWith(
405+ gridStyle: GridStyles.dots,
406+ );
407+ ```
408+
409+ </details >
410+
411+ <details >
412+ <summary ><strong >Cross Grid Style</strong ></summary >
413+
414+ Features small crosses at grid intersections, offering a balance between
415+ visibility and subtlety.
416+
417+ ``` dart
418+ final theme = NodeFlowTheme.light.copyWith(
419+ gridStyle: GridStyles.cross,
420+ );
421+ ```
422+
423+ </details >
424+
425+ <details >
426+ <summary ><strong >Hierarchical Grid Style</strong ></summary >
427+
428+ Renders both minor and major grid lines at different intervals, with major lines
429+ appearing every 5 minor grid cells by default. Useful for complex diagrams
430+ requiring multiple levels of visual organization.
431+
432+ ``` dart
433+ // Use default hierarchical (5x multiplier)
434+ final theme = NodeFlowTheme.light.copyWith(
435+ gridStyle: GridStyles.hierarchical,
436+ );
437+
438+ // Custom multiplier for major grid lines
439+ final customTheme = NodeFlowTheme.light.copyWith(
440+ gridStyle: HierarchicalGridStyle(majorGridMultiplier: 10),
441+ );
442+ ```
443+
444+ </details >
445+
446+ <details >
447+ <summary ><strong >None Grid Style</strong ></summary >
448+
449+ Provides a clean canvas with no background pattern.
450+
451+ ``` dart
452+ final theme = NodeFlowTheme.light.copyWith(
453+ gridStyle: GridStyles.none,
454+ );
455+ ```
456+
457+ </details >
458+
459+ ### Customizing Grid Appearance
460+
461+ Control the grid size and color through the theme:
462+
463+ ``` dart
464+ final theme = NodeFlowTheme.light.copyWith(
465+ gridStyle: GridStyles.lines,
466+ gridSize: 20.0, // Size of each grid cell
467+ gridColor: Colors.grey[300], // Grid line/dot color
468+ );
469+ ```
320470
321471---
322472
@@ -1056,10 +1206,15 @@ connectionTheme: ConnectionTheme(
10561206
10571207### Connection Labels
10581208
1059- Add labels to connections:
1209+ Add informative labels to connections at start, center, or end positions to
1210+ clarify data flow, transformation steps, or relationship types.
1211+
1212+ #### Basic Label Usage
10601213
10611214<details >
1062- <summary ><strong >Connection Label Example</strong ></summary >
1215+ <summary ><strong >Single Center Label</strong ></summary >
1216+
1217+ The simplest way to add a label is using the center position:
10631218
10641219``` dart
10651220final connection = Connection(
@@ -1068,24 +1223,154 @@ final connection = Connection(
10681223 sourcePortId: 'output',
10691224 targetNodeId: 'node-2',
10701225 targetPortId: 'input',
1071- label: 'Data Flow', // Add label
1226+ label: ConnectionLabel.center(text: 'Data Flow'),
10721227);
1228+ ```
10731229
1074- // Customize label appearance in theme
1075- labelTheme: LabelTheme(
1076- color: Colors.black87,
1077- fontSize: 11.0,
1078- fontWeight: FontWeight.w500,
1079- backgroundColor: Colors.white,
1080- borderColor: Colors.grey.shade300,
1081- borderWidth: 1.0,
1082- horizontalOffset: 8.0,
1083- verticalOffset: 8.0,
1084- )
1230+ </details >
1231+
1232+ #### Multiple Labels Per Connection
1233+
1234+ <details >
1235+ <summary ><strong >Start, Center, and End Labels</strong ></summary >
1236+
1237+ Each connection can have up to three labels at different positions:
1238+
1239+ ``` dart
1240+ final connection = Connection(
1241+ id: 'conn-1',
1242+ sourceNodeId: 'node-1',
1243+ sourcePortId: 'output',
1244+ targetNodeId: 'node-2',
1245+ targetPortId: 'input',
1246+
1247+ // Label at the start (anchor 0.0)
1248+ startLabel: ConnectionLabel.start(
1249+ text: 'Start',
1250+ offset: 10.0, // 10px perpendicular offset from path
1251+ ),
1252+
1253+ // Label at the center (anchor 0.5)
1254+ label: ConnectionLabel.center(
1255+ text: 'Processing',
1256+ offset: -15.0, // negative offset = other side of path
1257+ ),
1258+
1259+ // Label at the end (anchor 1.0)
1260+ endLabel: ConnectionLabel.end(
1261+ text: 'Complete',
1262+ offset: 10.0,
1263+ ),
1264+ );
1265+ ```
1266+
1267+ </details >
1268+
1269+ #### Label Positioning
1270+
1271+ <details >
1272+ <summary ><strong >Understanding Anchor and Offset</strong ></summary >
1273+
1274+ Labels are positioned using two properties:
1275+
1276+ - ** anchor** : Position along the path (0.0 to 1.0)
1277+ - 0.0 = source/start of connection
1278+ - 0.5 = center of connection
1279+ - 1.0 = target/end of connection
1280+
1281+ - ** offset** : Perpendicular distance from the path
1282+ - Positive values: offset to one side
1283+ - Negative values: offset to the other side
1284+ - 0.0: label sits directly on the path
1285+
1286+ ``` dart
1287+ // Custom anchor position (0.75 = 75% along the path)
1288+ final label = ConnectionLabel(
1289+ text: 'Almost there',
1290+ anchor: 0.75,
1291+ offset: 20.0,
1292+ );
10851293```
10861294
10871295</details >
10881296
1297+ #### Dynamic Label Updates
1298+
1299+ <details >
1300+ <summary ><strong >Updating Labels at Runtime</strong ></summary >
1301+
1302+ Labels are reactive and can be updated dynamically:
1303+
1304+ ``` dart
1305+ // Update just the text
1306+ connection.label?.updateText('New status');
1307+
1308+ // Update just the offset
1309+ connection.label?.updateOffset(15.0);
1310+
1311+ // Update just the anchor position
1312+ connection.label?.updateAnchor(0.7);
1313+
1314+ // Update multiple properties at once
1315+ connection.label?.update(
1316+ text: 'Updated',
1317+ anchor: 0.6,
1318+ offset: -10.0,
1319+ );
1320+
1321+ // Add or remove labels
1322+ connection.startLabel = ConnectionLabel.start(text: 'New start label');
1323+ connection.label = null; // Remove center label
1324+ ```
1325+
1326+ </details >
1327+
1328+ #### Theming Connection Labels
1329+
1330+ <details >
1331+ <summary ><strong >Global Label Styling</strong ></summary >
1332+
1333+ Customize label appearance for all connections using the theme:
1334+
1335+ ``` dart
1336+ final theme = NodeFlowTheme.light.copyWith(
1337+ labelTheme: LabelTheme(
1338+ // Text styling
1339+ textStyle: TextStyle(
1340+ color: Colors.black87,
1341+ fontSize: 12.0,
1342+ fontWeight: FontWeight.w500,
1343+ ),
1344+
1345+ // Background and border
1346+ backgroundColor: Colors.white,
1347+ border: Border.all(
1348+ color: Colors.grey.shade300,
1349+ width: 1.0,
1350+ ),
1351+
1352+ // Size constraints
1353+ maxWidth: 150.0, // Maximum label width
1354+ maxLines: 2, // Maximum number of text lines
1355+
1356+ // Padding
1357+ padding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
1358+ ),
1359+ );
1360+
1361+ controller.setTheme(theme);
1362+ ```
1363+
1364+ </details >
1365+
1366+ > [ !TIP] Use connection labels to annotate data transformations, display
1367+ > relationship types, show flow conditions, or add any contextual information
1368+ > that helps users understand the connections in your diagram.
1369+
1370+ > [ !NOTE] For a complete interactive example with theme customization, see the
1371+ > [ Connection Labels demo] ( ../../demo/lib/examples/advanced/connection_labels.dart )
1372+ > in the demo app.
1373+
10891374---
10901375
10911376## Annotations
0 commit comments