vyuh_diagram_core
A headless diagram engine for Dart: shapes, connectors, transactions and undo, with no Flutter required.
Vyuh Diagram · Docs · Examples · API reference
Create, connect and edit diagrams from plain Dart. The DiagramController
applies every change as an undoable transaction, so the same code drives a
Flutter app, a server, a command-line tool or an AI agent, and they all share
one rules and history model.
What you get
- Content: basic shapes, plain text, straight connectors with arrowheads and freehand drawing.
- Editing: selection, grouping, moving, styling and connecting, each as a
single undo step;
controller.edits.batchgroups several into one. - Two ways to call:
controller.createShape(...)returns an id and throws when an edit is denied;controller.edits.createShape(...)returns anEditResultto inspect instead. Both use the same rules and history. - Collaboration-ready: add another controller to
controller.diagramfor a person or agent working on the same document. - Extensible: install extensions once through
DiagramConfiguration. The grid is installed but hidden; enable it withGridExtension(visible: true, snap: true).
Install
dart pub add vyuh_diagram_core
For a Flutter app, add vyuh_diagram_flutter,
which includes this package.
Create and connect
import 'package:vyuh_diagram_core/vyuh_diagram_core.dart';
final controller = DiagramController();
final start = controller.createShape(
Shapes.rectangle, at: DiagramPoint.zero, text: 'Start',
);
final finish = controller.createShape(
Shapes.rectangle, at: const DiagramPoint(240, 0), text: 'Finish',
);
controller.connect(start, finish);
controller.undo();
controller.redo();
// Dispose the controller when its owner closes.
Inspect a result
final result = controller.edits.createShape(
Shapes.rectangle, at: DiagramPoint.zero, text: 'Hello',
);
if (result.allowed) {
print('Created ${result.id}');
} else {
print('Denied: ${result.reason}');
}
A complete headless program, including batching, edits and saving, is in the package's example.
Learn more
- Hello world
- Controller methods and configuration
- Working with agents
- Persistence with
vyuh_diagram_codec_json
Where this fits
Vyuh Diagram is a diagram editor you embed in your own app. Five packages are open source (Apache-2.0) on pub.dev:
| Package | What it is |
|---|---|
vyuh_diagram_types |
Immutable document model and geometry. |
vyuh_diagram_core |
Controller, edits and history, in pure Dart. |
vyuh_diagram_flutter |
Flutter canvas, input and rendering. |
vyuh_diagram_codec_json |
Save and load diagrams as JSON. |
vyuh_diagram_codec_svg |
Export diagrams as SVG; import SVG shapes. |
Commercial extensions add the editor, shape libraries, automatic layout, rich text, tables, a minimap and more. They come from pub.vyuh.tech; see package access and the full package list.
License
Apache License, Version 2.0 (text). Third-party materials keep their own licenses; see the notices shipped in this package.
Libraries
- adapter
- Integration surface for diagram platform adapters, not the consumer API.
- extension_api
- What extension authors need beside the application surface: shape definitions and their parts, tools, verbs, text, content, route, arrowhead and port definitions, the resolved scene, the property schema and the extension assembly.
- testing
- Fixtures shared by the SDK's own tests and by extension authors testing their contributions.
- vyuh_diagram_core
- Vyuh Diagram: a controller over a diagram document, the extensions it installs, their options and the application's rules.
- vyuh_diagram_pango
- Optional native server text shaping. Import explicitly on Dart VM hosts. Requires PangoFT2/Fontconfig; never imported by the browser-facing library.