Vyuh Diagram

vyuh_diagram_types on pub.dev pub points Apache-2.0

vyuh_diagram_types

Immutable document model, shapes, text and geometry for Vyuh Diagram, in pure Dart.

Vyuh Diagram · Docs · Examples · API reference

A diagram is plain data. This package defines that data: documents, shapes, text, connectors, styles and the geometry they sit on. Everything is immutable and has no Flutter dependency, so the same model runs in an app, a server, a command-line tool or an agent.

What is inside

  • Documents and elements: DiagramDocument holds ShapeElement, TextElement and connector elements, each with an id, frame, z-order, visibility and lock state.
  • Geometry: DiagramPoint, DiagramSize and DiagramRect.
  • Appearance: ShapeStyle, DiagramColor, StrokeStyle and arrowheads.
  • Text: stories made of paragraphs and runs, with alignment and sizing modes.
  • Output contracts: the options and results that the SVG and image exporters share.

Most apps never import this package directly: vyuh_diagram_core and vyuh_diagram_flutter re-export what they need. Depend on it when you only build, inspect or transform documents and do not need a controller.

Install

dart pub add vyuh_diagram_types

Build a document

import 'package:vyuh_diagram_types/vyuh_diagram_types.dart';

final document = DiagramDocument(
  id: 'plan',
  revision: 0,
  elements: [
    ShapeElement(
      id: 'start',
      type: Shapes.rectangle,
      frame: const DiagramRect.fromLTWH(0, 0, 160, 80),
    ),
  ],
);

final start = document.elementById('start') as ShapeElement;
print(start.frame); // DiagramRect(0.0, 0.0, 160.0, 80.0)

Documents are values: to change one, use a controller from vyuh_diagram_core, which applies edits as undoable transactions and returns a new document.

Learn more

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

vyuh_diagram_types
The immutable document model of Vyuh Diagram, in pure Dart with no Flutter dependency.