Installation
| Requirement | Version |
|---|---|
| Flutter | 3.47 or newer |
| Dart | 3.12 or newer |
| Registry | An account on pub.vyuh.tech with access to the Document packages |
| Package cohort | 0.19.3 (every Document package is released at the same version) |
1. Add a registry token
The packages live on the private registry https://pub.vyuh.tech. Create a token in your account and register it:
sh
dart pub token add https://pub.vyuh.techIn CI, read it from an environment variable:
sh
dart pub token add https://pub.vyuh.tech --env-var PUB_VYUH_TOKENKeep tokens out of source control
Never commit the token or put it in pubspec.yaml.
2. Add the packages
Every package comes from the registry and shares one version.
yaml
dependencies:
flutter:
sdk: flutter
vyuh_document:
hosted: https://pub.vyuh.tech
version: ^0.19.3
vyuh_document_editor:
hosted: https://pub.vyuh.tech
version: ^0.19.3
flutter:
uses-material-design: truesh
flutter pub add vyuh_document --hosted-url https://pub.vyuh.tech
flutter pub add vyuh_document_editor --hosted-url https://pub.vyuh.techThen resolve:
sh
flutter pub getAdd other packages only when you import them. Packages lists them all.
A dependency doesn't switch a feature on
The configuration or installed extensions decide what the editor can do. See Choose extensions.
3. Check the setup
dart
import 'package:flutter/material.dart';
import 'package:vyuh_document/vyuh_document.dart' show DocumentConfiguration, DocumentController;
import 'package:vyuh_document_editor/document_editor.dart';
void main() => runApp(MaterialApp(
home: Scaffold(
body: DocumentEditor(
controller: DocumentController(DocumentConfiguration.richText),
surface: const DocumentSurface.pageless(maxWidth: 720),
chrome: EditorChrome.floating,
),
),
));Type a sentence, select a word and make it bold from the bubble. The tutorial builds from here.
Choose your imports
| Library | Use it for |
|---|---|
package:vyuh_document/vyuh_document.dart | The typed API: Document, DocumentConfiguration, DocumentController, commands, Result and errors. Pure Dart. |
package:vyuh_document/elements.dart | Paragraph, Heading, Footnote, Endnote. |
package:vyuh_document_elements/vyuh_document_elements.dart | Every first-party element plus notesConfiguration and documentConfiguration. |
package:vyuh_document_editor/document_editor.dart | DocumentEditor(controller:, surface:, chrome:) for a typed DocumentController. |
package:vyuh_document_editor/vyuh_document_editor.dart | The editor runtime: DocumentEditorController, the runtime DocumentEditor, configuration, sources, fonts and images. Re-exports the canonical model (types.dart). |
package:vyuh_document/paragraph_extension.dart | Text, mark, paragraph, heading and link methods on DocumentEditorController. |
package:vyuh_document_editor/document_editor_workspace.dart | Ribbon, Properties, dialogs, rulers and workspace scaffolding. |
package:vyuh_document_editor/document_editor_extensions.dart | Extension classes (TableDocumentExtension, ImageDocumentExtension, ...) and authoring contracts. |
Two Document and DocumentEditor types
The typed API and the runtime each export a Document and a DocumentEditor. Use one per file, or import one with a prefix (as core). Hide Flutter's Table, Image and Alignment where they clash.
Next
- Tutorial: grow a rich-text field into a full document editor.
- Packages: every package, its layer and its dependencies.
- Typed Document API: documents, controllers and commands without Flutter.