Vector diagrams
vyuh_document_diagram embeds rich interactive Vyuh Diagram canvases directly inside a document — supporting drag-and-drop node/connector editing sessions, bounded fit sizing, alt text, and vector PDF/SVG output.
- Optional heavy plugin: Separate package pair keeping base apps lean
- Pure-Dart package:
package:vyuh_document_diagram/vyuh_document_diagram.dart - Flutter package:
package:vyuh_document_diagram_flutter/vyuh_document_diagram_flutter.dart - Action namespace:
DiagramActions(insert,edit)
Installation
yaml
dependencies:
vyuh_document_diagram:
hosted: https://pub.vyuh.tech
version: ^0.90.0
vyuh_document_diagram_flutter:
hosted: https://pub.vyuh.tech
version: ^0.90.0sh
flutter pub add vyuh_document_diagram vyuh_document_diagram_flutter --hosted-url https://pub.vyuh.techQuick example
dart
import 'package:vyuh_document_flutter/editor.dart';
import 'package:vyuh_document_diagram_flutter/vyuh_document_diagram_flutter.dart';
final config = documentConfiguration.withElements([Diagram.element]);
final controller = DocumentEditorController(
document: Document.of(config, [
Diagram(
width: 520,
height: 320,
altText: 'Service topology diagram',
),
]),
extensions: [
...DocumentEditorElements.defaults,
const DiagramEditorExtension(),
],
);What you can configure
| Property / Capability | Purpose |
|---|---|
width, height | Canvas display dimensions in points, constrained safely to page width via bounded-fit layout |
altText | Accessibility description for screen readers, HTML, and DOCX |
| Interactive edit session | Opens a live Vyuh Diagram editing session (DiagramEditSession) that commits updated vector artifacts back into canonical document history |
| Localization | Customize diagram chrome strings via DiagramDocumentLocalizations |
Actions & commands
| Action ID / Command | Effect |
|---|---|
DiagramActions.insert | Insert a new embedded vector diagram block |
DiagramActions.edit | Launch the interactive diagram editor for the selected block |
ResizeDiagram, SetDiagramAltText | Pure-Dart commands updating dimensions and alt text canonically |
Restricting usage
- View-only embedded diagrams: Set
DocumentInteractionMode.readOnlyor gateDiagramActions.editinDocumentPolicyso readers see crisp vector diagrams without launching the canvas editor.
Format parity
| DOCX | HTML | Markdown | |
|---|---|---|---|
| Embedded crisp diagram graphic with alt text | Direct vector rendering on the exact paginated canvas | Embedded SVG with aria-label | Image/block representation with alt text |