SmartEditorController class

The public controller for SmartEditor.

Create an instance and pass it to SmartEditor. Use it to programmatically get/set content, apply formatting, manage undo/redo, and more.

final controller = SmartEditorController();

// Get HTML
String html = await controller.getText();

// Set HTML
controller.setText('<p>Hello <b>World</b></p>');
Inheritance

Constructors

SmartEditorController({bool processInputHtml = true, bool processOutputHtml = true, bool processNewLineAsBr = false})

Properties

canRedo bool
Whether there are actions to redo.
no setter
canUndo bool
Whether there are actions to undo.
no setter
characterCount int
Returns the current character count.
no setter
document Document
The current document
no setter
documentController → DocumentController
The internal document controller
no setter
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
isDisabled bool
Whether the editor is currently disabled.
no setter
onTagSerialize String? Function(SmartTagType type, String tag, Map<String, String> attributes, Map<String, String> styles, String content)?
Custom tag serialization callback.
getter/setter pair
processInputHtml bool
final
processNewLineAsBr bool
final
processOutputHtml bool
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
attachEditor(SmartEditorWidgetState editor) → void
Register the editor widget (called internally by SmartEditor)
attachToolbar(SmartToolbarState toolbar) → void
Register the toolbar widget (called internally by SmartEditor)
clear() → void
Clears all content from the editor.
clearFocus() → void
Clears focus from the editor.
disable() → void
Disables the editor (read-only mode).
dispose() → void
Discards any resources used by the object.
inherited
enable() → void
Enables the editor for editing.
getText() Future<String>
Gets the HTML content from the editor.
insertHtml(String html) → void
Inserts HTML at the current cursor position. Parses the HTML and inserts the resulting text content.
insertText(String text) → void
Inserts plain text at the current cursor position.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
redo() → void
Redoes 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
setBlockType(BlockType type) → void
Changes the current block to a specific heading level (1-6) or back to paragraph.
setFocus() → void
Sets focus to the editor.
setHint(String text) → void
Sets the hint/placeholder text.
setText(String html) → void
Sets the editor content from an HTML string.
toggleBold() → void
Toggles bold on the current selection.
toggleItalic() → void
Toggles italic on the current selection.
toggleStrikethrough() → void
Toggles strikethrough on the current selection.
toggleUnderline() → void
Toggles underline on the current selection.
toString() String
A string representation of this object.
inherited
undo() → void
Undoes the last action.

Operators

operator ==(Object other) bool
The equality operator.
inherited