TextEditor class

A higher-level editor surface built on top of TextArea.

TextEditor adds lightweight chrome around the raw textarea: a title row, dirty/save status, cursor/length status, and a compact shortcuts bar.

final controller = TextAreaController(text: 'notes');

TextEditor(
  title: 'Scratchpad',
  controller: controller,
  height: 8,
  onSave: (value) => saveDraft(value),
)
Inheritance

Constructors

TextEditor({String title = 'Editor', TextAreaController? controller, TextAreaModel? model, FocusController? focusController, String? focusId, bool autofocus = false, bool enabled = true, String? prompt, String? placeholder, int? width, int height = 8, bool showLineNumbers = true, bool softWrap = true, bool? useVirtualCursor, TextAreaKeyMap? keyMap, TextAreaStyles? styles, CursorModel? cursor, bool showHelpBar = true, bool helpExpanded = false, Widget? headerTrailing, Widget? footer, TextChangedCallback? onChanged, ValueCmdCallback<String>? onSave, ValueCmdCallback<KeyMsg>? onKey, List<KeyBinding> extraHelpBindings = const [], bool showSaveStatus = true, String cleanLabel = 'saved', String dirtyLabel = 'modified', int indentWidth = 2, Key? key})

Properties

accessibilityLabel String?
Optional accessibility label.
no setterinherited
accessibilityRole String
Optional accessibility role.
no setterinherited
autofocus bool
Whether to request focus on first build.
final
children List<Widget>
Child widgets that receive forwarded messages.
no setterinherited
cleanLabel String
Header label shown after the current contents have been saved.
final
controller TextAreaController?
Optional textarea controller.
final
cursor CursorModel?
Optional cursor model.
final
debugRenderObjectPassthrough bool
Whether this widget is intentionally transparent to render-object layouts.
no setterinherited
degradationSignal WidgetDegradationSignal
Signal that controls this widget's render budget behavior.
no setterinherited
dirtyLabel String
Header label shown when the contents have unsaved changes.
final
enabled bool
Whether input is enabled.
final
extraHelpBindings List<KeyBinding>
Optional additional help bindings to show in the footer.
final
focusable bool
Whether this widget can receive keyboard focus.
no setterinherited
focusController FocusController?
Optional focus controller for focus coordination.
final
focusId String?
Optional focus identifier.
final
Optional footer widget shown below the help bar.
final
hashCode int
The hash code for this object.
no setterinherited
headerTrailing Widget?
Optional trailing widget in the header row.
final
height int
Visible editor height in rows.
final
helpExpanded bool
Whether to expand the help footer into grouped mode.
final
id String
Unique identifier for this widget.
no setterinherited
indentWidth int
Number of spaces inserted when Tab is pressed inside the editor.
final
key Key?
Key for preserving widget identity.
finalinherited
keyMap TextAreaKeyMap?
Optional key bindings for the embedded textarea.
final
model TextAreaModel?
Optional textarea model.
final
onChanged TextChangedCallback?
Called when the text changes.
final
onKey ValueCmdCallback<KeyMsg>?
Optional extra key handler invoked after search/goto handling and before the default indent/save shortcuts.
final
onSave ValueCmdCallback<String>?
Called when the user saves the current editor contents with Ctrl+S.
final
placeholder String?
Placeholder text when empty.
final
prompt String?
Prompt displayed before each line.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showHelpBar bool
Whether to show the compact help footer.
final
showLineNumbers bool
Whether to show line numbers.
final
showSaveStatus bool
Whether to show the clean/dirty status label in the header.
final
softWrap bool
Whether to soft-wrap long lines.
final
styles TextAreaStyles?
Optional textarea styles.
final
theme Theme
Access the current theme.
no setterinherited
title String
Title shown in the editor header.
final
useVirtualCursor bool?
Whether to render a virtual cursor.
final
width int?
Explicit editor width in cells.
final

Methods

buildCachedView<T>(T builder(), Object? cacheKey) → T
Returns a cached view if the cache key matches.
inherited
createState() State<StatefulWidget>
Creates the mutable State associated with this widget.
override
handleInit() Cmd?
Override this instead of init for widget-specific initialization.
inherited
handleIntercept(Msg msg) → (Widget, Cmd?)
Override this to handle messages before they reach children.
inherited
handleUpdate(Msg msg) → (Widget, Cmd?)
Override this to handle messages specific to this widget.
inherited
init() Cmd?
Called once when the widget is first mounted.
inherited
invalidateCachedView() → void
Clears any cached view for this widget.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldRenderAt(DegradationLevel degradationLevel, {required bool subtreeHasFocusedWidget}) bool
Whether this widget should participate in the current render when degradationLevel is active.
inherited
toString() String
A string representation of this object.
inherited
update(Msg msg) → (Model, Cmd?)
Handles messages by forwarding to children then calling handleUpdate.
inherited
view() Object
Renders the widget to a string or View.
inherited

Operators

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