vyuh_diagram_core 3.2.0
vyuh_diagram_core: ^3.2.0 copied to clipboard
Headless diagram engine for Dart: create shapes and connectors, edit through transactions with undo and redo, and extend with plugins. No Flutter needed.
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.