Installation
| Requirement | Version |
|---|---|
| Flutter | 3.50 or newer |
| Dart | 3.14 or newer |
| Registry | An account on pub.vyuh.tech with access to the Document packages |
| Package cohort | 0.65.2 (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.65.2
vyuh_document_editor:
hosted: https://pub.vyuh.tech
version: ^0.65.2
vyuh_document_editor_elements:
hosted: https://pub.vyuh.tech
version: ^0.65.2
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.tech
flutter pub add vyuh_document_editor_elements --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 DocumentController;
import 'package:vyuh_document_editor/document_editor.dart';
// The one list: what this editor holds. Paragraphs and text.
const extensions = DocumentExtension.richText;
void main() => runApp(MaterialApp(
home: Scaffold(
body: DocumentEditor(
extensions: extensions,
controller: DocumentController(documentConfigurationOf(extensions)),
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, PageBreak, ColumnBreak. |
package:vyuh_document_extension_heading/element.dart | Heading, HeadingLevel, HeadingAddress. |
package:vyuh_document_extension_notes/element.dart | Footnote, Endnote, and their commands. |
package:vyuh_document_elements/vyuh_document_elements.dart | Every first-party element plus the preset configurations: paragraphsConfiguration, writingConfiguration, 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_elements/vyuh_document_editor_elements.dart | DocumentEditorElements.defaults and defaultsWith(...): the default extension list. |
package:vyuh_document_editor/document_editor_workspace.dart | Ribbon, Properties, dialogs, rulers and workspace scaffolding. |
package:vyuh_document_editor/document_editor_extensions.dart | Authoring contracts for extensions, and the paragraph, list and field extension classes. Each other element's extension is in its _editor package. |
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.