FluentDocument class
Constructors
FluentDocument ({Root ? content })
FluentDocument.fromJson (Map <String , dynamic > json )
Creates a FluentDocument from a JSON map (result of jsonDecode).
Supports both the new format (with "nodes" and "settings") and
the legacy format (Root JSON directly).
factory
Properties
cachedCursorContainerId
→ String ?
O(1) when pre-computed, falls back to O(n) otherwise (e.g. drag selection).
no setter
canRedo
→ bool
Checks if redo is possible
no setter
canUndo
→ bool
Checks if undo is possible
no setter
caretStops
→ List <CaretStop >
no setter
clipboardPayload
↔ String ?
Internal clipboard payload (JSON serialized) with preserved formatting.
getter/setter pair
Optional comment plugin. When set, the editor will display
comment highlights, a sidebar, and allow adding / managing comments.
getter/setter pair
containerOrder
→ List <String >
no setter
content
→ Root
no setter
contentVersion
→ int
no setter
cursor
→ Cursor
no setter
cursorOnlyChange
→ bool
True while listeners are being notified for a cursor-only change.
Widgets that do expensive work on every document change can check this
flag and skip irrelevant updates (e.g. toolbar style scan, full tree
rebuild) when the document text / structure did not change.
no setter
documentLanguage
↔ String
Document-level language (BCP-47 code). Defaults to the language
selected in DocumentLanguageController or the system locale.
getter/setter pair
editorFocusNode
→ FocusNode
FocusNode for the editing area. The toolbar can request focus
after an interaction (e.g., font selection) by calling requestEditorFocus .
final
eventHandler
→ EventHandler
no setter
hashCode
→ int
The hash code for this object.
no setter inherited
hasListeners
→ bool
Whether any listeners are currently registered.
no setter inherited
labels
↔ FluentEditorLabels ?
Localization labels for the user interface.
getter/setter pair
logicalLines
→ List <LogicalLine >
no setter
mobileTextFieldFocusNode
↔ FocusNode ?
FocusNode for the hidden TextField used for mobile keyboard support.
Exposed to allow requesting focus on tap (opens the virtual keyboard
on both native mobile and mobile web).
getter/setter pair
paragraphRegistry
→ ParagraphRegistry
no setter
pendingColor
↔ String ?
Active text color for collapsed cursor. Null = auto.
getter/setter pair
pendingFontFamily
↔ String
Active font family for collapsed cursor (persistent like Word).
When the user types, new text inherits this font.
getter/setter pair
pendingFontSize
↔ double
Active font size for collapsed cursor.
getter/setter pair
pendingHighlightColor
↔ String ?
Active highlight color for collapsed cursor. Null = none.
getter/setter pair
pendingIndent
↔ int
Active indentation for collapsed cursor.
Used when creating a new paragraph.
getter/setter pair
pendingLineHeight
↔ double
Active line height for collapsed cursor.
getter/setter pair
pendingSpacingAfter
↔ double
Spacing after paragraph in points.
getter/setter pair
pendingSpacingBefore
↔ double
Spacing before paragraph in points.
getter/setter pair
pendingStyle
↔ ParagraphStyle
Active style for collapsed cursor.
Used when creating a new paragraph.
getter/setter pair
pendingStyles
↔ List <String >
Active inline styles for collapsed cursor (bold, italic, underline).
getter/setter pair
pendingTextAlign
↔ String
Active text alignment for collapsed cursor (left, center, right).
Used when creating a new paragraph.
getter/setter pair
runtimeType
→ Type
A representation of the runtime type of the object.
no setter inherited
selectionManager
→ SelectionManager
no setter
spellCheckProvider
↔ SpellCheckProvider ?
Optional spell-check plugin. When set, the editor will use it
for underlining misspelled words and providing suggestions.
getter/setter pair
stopsByContainer
→ Map <String , List <CaretStop > >
no setter
undoRedoManager
→ UndoRedoManager
no setter
Methods
addListener (VoidCallback listener )
→ void
Register a closure to be called when the object changes.
inherited
clearUndoRedo ()
→ void
Clears undo/redo stacks
cursorOnlyUpdate ()
→ void
Notifies listeners for a cursor/selection-only change that does NOT
mutate the document structure or text. Crucially it does NOT invalidate
the content-derived caches (node index, caret-stop rail), so repeated
arrow navigation reuses them instead of rebuilding O(n) on every press.
dispose ()
→ void
Discards any resources used by the object.
inherited
findLogicalContainerId (String fragmentId )
→ String ?
Returns the id of the inline container that directly contains
the fragment (Paragraph inside a ListItem/Cell, or standalone Paragraph).
findParentCached (String childId )
→ String ?
O(1) lookup of the parent id of childId.
Returns null if childId is the root or not found.
findParentNodeId (String fragmentId )
→ String ?
Helper to get the parent node ID of a fragment
flattenContainer (FNode container )
→ List <(Fragment , int , int ) >
Returns the flattened fragment list for container with global
offsets, using the document cache when available.
forceNewAction ({String description = 'New action' })
→ void
Forces creation of a new action (not grouped)
getGlobalOffsetInParagraph (String paragraphId , String fragmentId , int localOffset )
→ int ?
Calculates the global offset within paragraphId for a local
(fragmentId, localOffset) pair. Returns null if the fragment is not found.
getKeyForNode (String nodeId )
→ GlobalKey <State <StatefulWidget > >
getNodePath (String nodeId )
→ List <int > ?
Gets the hierarchical path of a node in the document
getSelectionRangeCached (String nodeId )
→ ({String endFrag , int endOff , String startFrag , int startOff } )?
O(1) when pre-computed, falls back to O(n) otherwise (e.g. drag selection).
getSelectionRangeForNode (String nodeId )
→ ({String endFrag , int endOff , String startFrag , int startOff } )?
invalidateNodeIndex ()
→ void
Marks the id→node index as stale so it gets rebuilt on next lookup.
isNodeDirty (String nodeId )
→ bool
Returns true if nodeId was marked dirty by the last
notifyDocumentChanged call. If no specific dirty nodes were set,
returns true for all IDs (backward-compatible behaviour).
isNodeSelected (String nodeId )
→ bool
isNodeSelectedCached (String nodeId )
→ bool
O(1) when pre-computed, falls back to O(n) otherwise (e.g. drag selection).
load (List <FNode > data )
→ void
loadContent (Root newContent )
→ void
Loads new content into the document, resetting cursor and selection.
manageEvent (KeyEvent event )
→ void
nodeById (String id )
→ FNode ?
Returns the node with the given id in O(1) using a cached index.
The index is rebuilt lazily (single tree walk) only when the document
has changed since the last lookup.
nodePosition (String nodeId )
→ int ?
O(1) lookup of the document-order position of nodeId.
Returns null if the node is not found in the document.
noSuchMethod (Invocation invocation )
→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyDocumentChanged ({Set <String > ? affectedIds })
→ void
Notifies document listeners that the content changed.
Use this after undo/redo where updateContent must NOT be called
(it would create a new undo record).
notifyListeners ()
→ void
Call all the registered listeners.
inherited
notifyTextMutation (String paragraphId , int fromOffset , int delta )
→ void
Notifies the comment provider that text in paragraphId was mutated.
redo ()
→ bool
Executes redo of the last undone action
removeListener (VoidCallback listener )
→ void
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
requestEditorFocus ()
→ void
requestMobileKeyboardFocus ()
→ void
resolveCaretX (CaretStop stop )
→ double
Caret coordinate resolver for vertical navigation.
resolveCaretY (CaretStop stop )
→ double
saveState ({String description = 'Document change' , bool forceNewAction = false })
→ void
Begins capturing the old document state for a delta-based undo.
The delta is committed automatically by updateContent after the
mutation, producing a minimal undo record that stores only the
changed top-level nodes (50-100x smaller than a full snapshot).
syncPendingFontWithCursor ()
→ void
toJson ()
→ String
toString ()
→ String
A string representation of this object.
inherited
undo ()
→ bool
Executes undo of the last action
updateContent ()
→ void