DmCodeEditor class

A code editor widget that integrates with the DuskMoon design system.

Wraps CodeEditorWidget with automatic theme derivation from the ambient DuskMoon theme tree. Supply a language string (e.g. 'dart', 'python') for syntax highlighting — no engine imports required by the caller.

When no controller is provided, an internal EditorViewController is created and disposed automatically. When a controller is provided, the caller owns its lifecycle.

Example

DmCodeEditor(
  initialDoc: 'void main() {}',
  language: 'dart',
  onChanged: (text) => print(text),
)
Inheritance

Constructors

DmCodeEditor({Key? key, String? initialDoc, String? language, EditorTheme? theme, bool readOnly = false, bool lineNumbers = true, bool highlightActiveLine = true, ValueChanged<String>? onChanged, void onStateChanged(EditorState state)?, EditorViewController? controller, FocusNode? focusNode, bool autofocus = false, double? minHeight, double? maxHeight, EdgeInsets? padding, ScrollPhysics? scrollPhysics})
Creates a DmCodeEditor.
const

Properties

autofocus bool
Whether to focus the editor on mount.
final
controller EditorViewController?
External controller for programmatic access. When null, an internal controller is created and disposed by this widget.
final
focusNode FocusNode?
Optional external FocusNode.
final
hashCode int
The hash code for this object.
no setterinherited
highlightActiveLine bool
Whether to highlight the line containing the cursor.
final
initialDoc String?
Initial document text. Ignored when controller is provided, and also used when the widget transitions from an external controller to no controller (the document resets to initialDoc).
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
language String?
Language identifier for syntax highlighting (e.g. 'dart', 'python'). Case-insensitive. Unknown values are silently ignored (no highlighting).
final
lineNumbers bool
Whether to show line numbers in the gutter.
final
maxHeight double?
Maximum height of the editor.
final
minHeight double?
Minimum height of the editor.
final
onChanged ValueChanged<String>?
Called with the full document text whenever the editor content changes.
final
onStateChanged → void Function(EditorState state)?
Called with the full EditorState whenever the editor state changes.
final
padding EdgeInsets?
Padding around the editor content area.
final
readOnly bool
Whether the editor is read-only.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollPhysics ScrollPhysics?
Scroll physics for the editor's internal list.
final
theme EditorTheme?
Custom editor theme. When null, the theme is derived automatically from the ambient DuskMoon theme via DmCodeEditorTheme.fromContext.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<DmCodeEditor>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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