CanvasEditorController class

Primary Host API for the Canvas Editor Engine.

Create one controller, pass it to CanvasEditorWidget, and build Host UI (toolbars, panels) around stateStream / command methods.

Constructors

CanvasEditorController({DesignDocument? initialDocument, CanvasImageProvider? imageProvider, List<CustomNodeType<DesignNode>>? customNodeTypes, void onDocumentChanged(DesignDocument doc)?})
Creates a controller.

Properties

customNodeRegistry CustomNodeRegistry
Custom Node types scoped to this Controller.
final
document DesignDocument
Current Design Document (latest, including mid-gesture previews).
no setter
hashCode int
The hash code for this object.
no setterinherited
imageProvider CanvasImageProvider?
Resolves assetId image references (CDN URLs, assets, etc.).
final
onDocumentChanged → void Function(DesignDocument doc)?
Called when a Design Document change is committed (gesture end, add/delete, history session commit, undo/redo, load) — not on every mid-drag frame.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state CanvasEditorState
Current public editor snapshot (selection, undo flags, document).
no setter
stateStream Stream<CanvasEditorState>
Live Engine state for Host UI. Emits on selection and every document mutation, including mid-drag frames.
no setter

Methods

addImageNode({required String localPath, bool select = true}) → void
Adds an image Node from a local file path.
addTextNode({String? text, Offset? position, bool select = true}) → void
Adds a text Node. Defaults to centered placeholder text when text / position are omitted.
beginHistorySession() → void
Starts a history session so many live property updates become one undo step.
bringForward(String nodeId) → void
Moves nodeId one step up in z-order.
bringToFront(String nodeId) → void
Moves nodeId above all other Nodes.
clearBackgroundImage() → void
Clears Background Fill image and restores the solid color.
commitHistorySession() → void
Ends a beginHistorySession and pushes one undo entry when the document changed.
deleteNode(String nodeId) → void
Deletes the Node with nodeId.
dispose() → void
Releases streams and internal Engine resources. Call from Host dispose.
documentFromJson(Map<String, dynamic> json) DesignDocument
Parses JSON with this Controller's customNodeRegistry.
exportToPng({double pixelRatio = 2.0}) Future<Uint8List>
Renders the current Design Document to PNG bytes (same pipeline as the live canvas).
loadDocument(DesignDocument doc) → void
Replaces the current Design Document.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
redo() → void
Redoes the last undone change.
selectNode(String? nodeId) → void
Selects nodeId, or clears selection when null.
sendBackward(String nodeId) → void
Moves nodeId one step down in z-order.
sendToBack(String nodeId) → void
Moves nodeId below all other Nodes (above Background Fill).
setBackgroundImage({String? localPath, String? assetId}) → void
Sets Background Fill image. Pass either localPath or assetId, not both.
toString() String
A string representation of this object.
inherited
undo() → void
Undoes the last committed change.
updateBackground(String colorHex, {bool recordUndo = true}) → void
Sets Background Fill to a solid ARGB hex color (e.g. '#FFFFFFFF').
updateTextContent(String nodeId, String text, {bool recordUndo = true}) → void
Updates text content and reflows height. See updateTextStyle for undo coalescing.
updateTextStyle(String nodeId, {double? fontSize, String? textColor, String? fontFamily, int? fontWeight, double? lineHeight, double? letterSpacing, String? textAlign, bool recordUndo = true}) → void
Updates text style fields and reflows height to fit wrapped text (width held).

Operators

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