vyuh_diagram_codec_json 2.16.0
vyuh_diagram_codec_json: ^2.16.0 copied to clipboard
JSON codec for Vyuh Diagram.
vyuh_diagram_codec_json
Versioned JSON persistence for Vyuh Diagram documents.
Vyuh Diagram · Docs · Examples · API reference
Pure Dart, with no engine or Flutter dependency. vyuh_diagram_flutter
re-exports DiagramJsonCodec.
Install #
2.11 preserves JSON format 1. The Dart connector field is now route, while the
serialized field remains router; existing saved drawings require no key
migration.
dart pub add vyuh_diagram_codec_json --hosted-url https://pub.vyuh.tech
Register your registry token first with dart pub token add https://pub.vyuh.tech;
see package access.
Usage #
With a controller, pass the format; the installed extensions' codecs are used automatically:
final json = controller.save(DiagramJsonCodec.new);
controller.edits.load(json, format: DiagramJsonCodec.new);
final reopened = DiagramController.open(
json,
format: DiagramJsonCodec.new,
configuration: DiagramConfiguration(extensions: [EditorExtension()]),
);
On its own:
import 'package:vyuh_diagram_codec_json/vyuh_diagram_codec_json.dart';
import 'package:vyuh_diagram_types/vyuh_diagram_types.dart';
const codec = DiagramJsonCodec(DiagramModelCodecs.empty());
final json = codec.encode(document);
final restored = codec.decode(json);
Learn more #
License #
Licensed under the Apache License, Version 2.0. Third-party materials retain their own licenses and notices.