# bansalgaurav852/flutter-quill architecture

> Architecture diagram of the GitHub repository bansalgaurav852/flutter-quill, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bansalgaurav852/flutter-quill
- Repository: https://github.com/bansalgaurav852/flutter-quill

## Overview

1. **What this repo is**
   This is a Flutter monorepo centered on a rich text editor package, `flutter_quill`, plus a companion package, `flutter_quill_extensions`, and a full multi-platform example app. There is no backend or networked service layer; the core architecture is a client-side editor runtime.

2. **Top-level package boundaries**
   The main package lives under `lib/` and exposes the public API through `lib/flutter_quill.dart` and `lib/extensions.dart`. Most implementation details are hidden under `lib/src/`, which is split into models, editor widgets, utilities, themes, and translations. The extension package is a separate boundary for optional embed support.

3. **Document and data model layer**
   The editor uses Quill’s Delta-based document model. Key types are in `lib/src/models/documents/` and `lib/src/models/quill_delta.dart`: `Document`, `Delta`, `Attribute`, `History`, and the node hierarchy (`block`, `line`, `leaf`, `embeddable`, `container`, `node`). This layer is the source of truth for content, formatting, and undo/redo state.

4. **Editing pipeline**
   User actions are mediated by `QuillController` in `lib/src/widgets/controller.dart`. The controller sits between the UI and the document model, applying insert/format/delete rules from `lib/src/models/rules/`. The main flow is: input event → controller mutation → document/delta update → widget rebuild.

5. **Editor rendering and interaction**
   The main editing surface is in `lib/src/widgets/editor.dart` and `raw_editor/`. These widgets handle text input, cursor movement, selection, keyboard handling, and visual composition. Supporting widgets like `text_block.dart`, `text_line.dart`, `cursor.dart`, `float_cursor.dart`, and `text_selection.dart` render and manage the editor surface.

6. **Toolbar and command surface**
   The toolbar subsystem in `lib/src/widgets/toolbar/` provides the command layer for formatting and document operations: styles, headers, color, font family/size, alignment, lists, links, history, indent, search, and checklist toggles. Toolbar actions operate on the same `QuillController`, so the toolbar is not separate state; it is a command UI over the document model.

7. **Styling, themes, and localization**
   Visual configuration is handled by models in `lib/src/models/themes/` and default widget styles in `lib/src/widgets/default_styles.dart`. Text and toolbar labels are localized through `lib/src/translations/toolbar.i18n.dart` and `lib/translations.dart`, with locale selection supported by both editor and toolbar widgets.

8. **Embed architecture**
   Embeds are a first-class extension point but not all embed implementations live in the core package. The core editor supports embed nodes abstractly via `embeddable.dart`, `embeds.dart`, and the embed-related widget layer. Concrete image/video/formula implementations are split into `flutter_quill_extensions/lib/embeds/`, which provides:
   - embed builders for rendering,
   - toolbar buttons for inserting media,
   - utilities for picking media,
   - specialized widgets for image/video/YouTube/formula display.

9. **Serialization and persistence**
   Content is represented internally as Quill Delta and can be serialized to JSON. The README indicates the normal persistence path is `document.toDelta().toJson()` and restoration via `Document.fromJson(...)`. So the storage boundary is JSON delta, not a custom app-specific format.

10. **Platform-specific integration points**
   The editor is cross-platform, but media insertion depends on platform-specific picker implementations. The README and example show different hooks for web versus desktop/mobile: web needs custom image/embed builders and web image selection logic, while desktop needs file-pick implementations for toolbar image actions. This is why embed/media handling is delegated to the example and extension package rather than hardcoded in the core.

11. **Example app as the integration reference**
   The `example/` app is a full Flutter application that demonstrates how the package is meant to be composed. Its `lib/pages/home_page.dart` and `read_only_page.dart` likely showcase editable and view-only editor configurations. `widgets/demo_scaffold.dart` and `widgets/responsive_widget.dart` suggest the demo adapts layout to screen size and platform.

12. **Example platform shells**
   The example includes standard Flutter runners for Android, iOS, web, macOS, Linux, and Windows. These folders are mostly platform scaffolding; the actual editor behavior still comes from the shared Dart code in `example/lib/`. The `universal_ui/` layer is specifically there to abstract platform differences in UI/picking behavior.

13. **Assets and demo data**
   `example/assets/` contains sample JSON documents and fonts. These are part of the demo content pipeline: they let the example load prebuilt Quill documents and demonstrate font-family customization without any server dependency.

14. **Overall architecture in one sentence**
   The repo is a layered Flutter editor system: a Delta-based document model and command controller at the core, rendering and input widgets around it, optional embed/media implementations in a separate extensions package, and a multi-platform example app that wires the pieces together.

Main entry points: [`lib/src/widgets/editor.dart`](https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/editor.dart) (Editor surface), [`lib/flutter_quill.dart`](https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/flutter_quill.dart) (Public API), [`lib/src/widgets/controller.dart`](https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/controller.dart) (Controller), [`lib/src/widgets/toolbar.dart`](https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/toolbar.dart) (Toolbar)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core package"]
  node_core_api["Public API<br/>exports<br/>[flutter_quill.dart]"]
  node_core_models[("Document model<br/>delta model<br/>[document.dart]")]
  node_core_delta["Quill Delta<br/>serialization<br/>[quill_delta.dart]"]
  node_core_rules{{"Edit rules<br/>mutation rules<br/>[rule.dart]"}}
  node_core_controller["Controller<br/>editor state<br/>[controller.dart]"]
  node_core_editor["Editor surface<br/>rendering<br/>[editor.dart]"]
  node_core_raw["Raw editor<br/>input bridge"]
  node_core_text["Text layout<br/>composition<br/>[text_block.dart]"]
  node_core_toolbar["Toolbar<br/>command UI<br/>[toolbar.dart]"]
  node_core_style["Styles & theme<br/>presentation"]
  node_core_i18n["Translations<br/>localization<br/>[translations.dart]"]
  node_core_embeds["Core embeds<br/>embed layer<br/>[embeds.dart]"]
end

subgraph group_extensions["Extensions package"]
  node_ext_api["Extensions API<br/>exports"]
  node_ext_builders["Embed builders<br/>rendering<br/>[builders.dart]"]
  node_ext_toolbar["Media toolbar<br/>command UI<br/>[image_button.dart]"]
  node_ext_widgets["Media widgets<br/>embed UI<br/>[image.dart]"]
end

subgraph group_example["Example app"]
  node_example_app["Example app<br/>Flutter app<br/>[main.dart]"]
  node_example_home["Editor pages<br/>demo UI<br/>[home_page.dart]"]
  node_example_ui["Universal UI<br/>platform bridge<br/>[universal_ui.dart]"]
  node_example_assets["Demo assets<br/>sample data<br/>[sample_data.json]"]
end

node_core_api -->|"exposes"| node_core_models
node_core_api -->|"exposes"| node_core_controller
node_core_api -->|"exposes"| node_core_editor
node_core_api -->|"exposes"| node_core_toolbar
node_core_models -->|"serializes to"| node_core_delta
node_core_rules -->|"governs"| node_core_controller
node_core_controller -->|"mutates"| node_core_models
node_core_editor -->|"delegates input"| node_core_raw
node_core_editor -->|"composes"| node_core_text
node_core_editor -->|"renders embeds"| node_core_embeds
node_core_toolbar -->|"issues commands"| node_core_controller
node_core_style -->|"styles"| node_core_editor
node_core_style -->|"styles"| node_core_toolbar
node_core_i18n -->|"localizes"| node_core_toolbar
node_core_i18n -->|"localizes"| node_core_editor
node_ext_api -->|"exports"| node_ext_builders
node_ext_api -->|"exports"| node_ext_toolbar
node_ext_api -->|"exports"| node_ext_widgets
node_ext_builders -->|"implements"| node_core_embeds
node_ext_toolbar -->|"extends"| node_core_toolbar
node_ext_widgets -->|"specializes"| node_core_embeds
node_example_app -->|"uses"| node_core_api
node_example_app -->|"uses"| node_ext_api
node_example_app -->|"navigates"| node_example_home
node_example_home -->|"configures"| node_core_controller
node_example_home -->|"bridges platform"| node_example_ui
node_example_app -->|"loads"| node_example_assets

click node_core_api "https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/flutter_quill.dart"
click node_core_models "https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/models/documents/document.dart"
click node_core_delta "https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/models/quill_delta.dart"
click node_core_rules "https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/models/rules/rule.dart"
click node_core_controller "https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/controller.dart"
click node_core_editor "https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/editor.dart"
click node_core_raw "https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/raw_editor/raw_editor_state_text_input_client_mixin.dart"
click node_core_text "https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/text_block.dart"
click node_core_toolbar "https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/toolbar.dart"
click node_core_style "https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/default_styles.dart"
click node_core_i18n "https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/translations.dart"
click node_core_embeds "https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/embeds.dart"
click node_ext_api "https://github.com/bansalgaurav852/flutter-quill/blob/master/flutter_quill_extensions/lib/flutter_quill_extensions.dart"
click node_ext_builders "https://github.com/bansalgaurav852/flutter-quill/blob/master/flutter_quill_extensions/lib/embeds/builders.dart"
click node_ext_toolbar "https://github.com/bansalgaurav852/flutter-quill/blob/master/flutter_quill_extensions/lib/embeds/toolbar/image_button.dart"
click node_ext_widgets "https://github.com/bansalgaurav852/flutter-quill/blob/master/flutter_quill_extensions/lib/embeds/widgets/image.dart"
click node_example_app "https://github.com/bansalgaurav852/flutter-quill/blob/master/example/lib/main.dart"
click node_example_home "https://github.com/bansalgaurav852/flutter-quill/blob/master/example/lib/pages/home_page.dart"
click node_example_ui "https://github.com/bansalgaurav852/flutter-quill/blob/master/example/lib/universal_ui/universal_ui.dart"
click node_example_assets "https://github.com/bansalgaurav852/flutter-quill/blob/master/example/assets/sample_data.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_core_api,node_core_models,node_core_delta,node_core_rules,node_core_controller,node_core_editor,node_core_raw,node_core_text,node_core_toolbar,node_core_style,node_core_i18n,node_core_embeds toneBlue
class node_ext_api,node_ext_builders,node_ext_toolbar,node_ext_widgets toneAmber
class node_example_app,node_example_home,node_example_ui,node_example_assets toneMint
```

## Components

### Core package

Primary Flutter rich-text editor package and internal runtime.

- [Public API](https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/flutter_quill.dart): exports · Package entrypoints that expose the editor and extension surface. · `lib/flutter_quill.dart`
- [Document model](https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/models/documents/document.dart): delta model · Delta-based source of truth for content, formatting, and history. · `lib/src/models/documents/document.dart`
- [Quill Delta](https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/models/quill_delta.dart): serialization · Delta representation used for persistence and JSON interchange. · `lib/src/models/quill_delta.dart`
- [Edit rules](https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/models/rules/rule.dart): mutation rules · Insert, delete, and format rules applied during controller mutations. · `lib/src/models/rules/rule.dart`
- [Controller](https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/controller.dart): editor state · Coordinates user actions, document mutations, and selection state. · `lib/src/widgets/controller.dart`
- [Editor surface](https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/editor.dart): rendering · Main editable widget layer that composes input, selection, and document display. · `lib/src/widgets/editor.dart`
- [Raw editor](https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/raw_editor/raw_editor_state_text_input_client_mixin.dart): input bridge · Low-level text input, cursor, and selection integration for the editor. · `lib/src/widgets/raw_editor/raw_editor_state_text_input_client_mixin.dart`
- [Text layout](https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/text_block.dart): composition · Block, line, cursor, and selection widgets used to render editable content. · `lib/src/widgets/text_block.dart`
- [Toolbar](https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/toolbar.dart): command UI · Formatting and document-operation controls that act on the controller. · `lib/src/widgets/toolbar.dart`
- [Styles & theme](https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/default_styles.dart): presentation · Default styles, icon/dialog themes, and visual configuration models. · `lib/src/widgets/default_styles.dart`
- [Translations](https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/translations.dart): localization · Localized labels and toolbar strings for editor and toolbar widgets. · `lib/translations.dart`
- [Core embeds](https://github.com/bansalgaurav852/flutter-quill/blob/master/lib/src/widgets/embeds.dart): embed layer · Abstract embed nodes and editor-side embed handling in the core package. · `lib/src/widgets/embeds.dart`

### Extensions package

Optional embed/media support packaged separately from core.

- [Extensions API](https://github.com/bansalgaurav852/flutter-quill/blob/master/flutter_quill_extensions/lib/flutter_quill_extensions.dart): exports · Public entrypoint for optional media/embed extensions. · `flutter_quill_extensions/lib/flutter_quill_extensions.dart`
- [Embed builders](https://github.com/bansalgaurav852/flutter-quill/blob/master/flutter_quill_extensions/lib/embeds/builders.dart): rendering · Concrete builders for image, video, and YouTube embed rendering. · `flutter_quill_extensions/lib/embeds/builders.dart`
- [Media toolbar](https://github.com/bansalgaurav852/flutter-quill/blob/master/flutter_quill_extensions/lib/embeds/toolbar/image_button.dart): command UI · Buttons and helpers for inserting camera, image, video, and formula embeds. · `flutter_quill_extensions/lib/embeds/toolbar/image_button.dart`
- [Media widgets](https://github.com/bansalgaurav852/flutter-quill/blob/master/flutter_quill_extensions/lib/embeds/widgets/image.dart): embed UI · Specialized widgets for image resizing, video playback, and YouTube embeds. · `flutter_quill_extensions/lib/embeds/widgets/image.dart`

### Example app

Multi-platform demo wiring the editor into a Flutter application.

- [Example app](https://github.com/bansalgaurav852/flutter-quill/blob/master/example/lib/main.dart): Flutter app · Cross-platform demo application showing editable and read-only editor setups. · `example/lib/main.dart`
- [Editor pages](https://github.com/bansalgaurav852/flutter-quill/blob/master/example/lib/pages/home_page.dart): demo UI · Primary demo pages for editable and read-only editor configurations. · `example/lib/pages/home_page.dart`
- [Universal UI](https://github.com/bansalgaurav852/flutter-quill/blob/master/example/lib/universal_ui/universal_ui.dart): platform bridge · Abstraction layer for platform-specific picker and UI behavior in the demo. · `example/lib/universal_ui/universal_ui.dart`
- [Demo assets](https://github.com/bansalgaurav852/flutter-quill/blob/master/example/assets/sample_data.json): sample data · Sample JSON documents and fonts used by the example app. · `example/assets/sample_data.json`

## Connections

- Public API → Document model: exposes · Public package API re-exports the document layer.
- Public API → Controller: exposes · Public package API exposes editor/controller primitives.
- Public API → Editor surface: exposes · Public package API exposes the main editor widgets.
- Public API → Toolbar: exposes · Public package API exposes toolbar components.
- Document model → Quill Delta: serializes to · Documents are converted to Delta JSON for persistence.
- Edit rules → Controller: governs · Mutation rules shape how controller edits are applied.
- Controller → Document model: mutates · Controller applies document changes and selection updates.
- Editor surface → Raw editor: delegates input · Editor surface delegates text input and selection handling to raw editor layers.
- Editor surface → Text layout: composes · Editor surface is built from text layout and interaction widgets.
- Editor surface → Core embeds: renders embeds · Editor surface hosts abstract embed nodes.
- Toolbar → Controller: issues commands · Toolbar actions operate on the shared controller state.
- Styles & theme → Editor surface: styles · Default theme and style models configure editor appearance.
- Styles & theme → Toolbar: styles · Theme models also configure toolbar presentation.
- Translations → Toolbar: localizes · Translation strings feed toolbar labels and dialogs.
- Translations → Editor surface: localizes · Localization is shared by editor-facing widgets.
- Extensions API → Embed builders: exports · Extensions package exposes embed rendering builders.
- Extensions API → Media toolbar: exports · Extensions package exposes media insertion toolbar controls.
- Extensions API → Media widgets: exports · Extensions package exposes specialized media widgets.
- Embed builders → Core embeds: implements · Concrete builders attach to the core embed abstraction.
- Media toolbar → Toolbar: extends · Media actions plug into the shared toolbar/controller command surface.
- Media widgets → Core embeds: specializes · Media widgets render concrete embed types supported by the core editor.
- Example app → Public API: uses · Example app depends on the core editor package.
- Example app → Extensions API: uses · Example app depends on optional extension package features.
- Example app → Editor pages: navigates · App routes to editable and read-only demo pages.
- Editor pages → Controller: configures · Demo pages configure the controller and editor behavior.
- Editor pages → Universal UI: bridges platform · Demo pages rely on platform-abstracted UI and picker hooks.
- Example app → Demo assets: loads · Demo loads sample documents and fonts from assets.
