TextEditingController class

A controller for managing text content, cursor position, and selection state.

Notifies listeners when the text or selection changes. Use with TextField for programmatic control over text input.

Inheritance

Constructors

TextEditingController()

Properties

cursorPosition int
The current cursor position within the text.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
hasSelection bool
Whether a range of text is currently selected.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selection TextSelection?
The current text selection, or null if no text is selected.
no setter
text String
The current text content.
getter/setter pair

Methods

addListener(dynamic listener()) → void
Register a closure to be called when the object changes.
inherited
clear() → void
Clears all text and resets the cursor to the start.
clearSelection() → void
Clears the current text selection without modifying the text.
copy() Future<void>
Copies the selected text to the clipboard.
cut() Future<void>
Copies the selected text to the clipboard and removes it from the text.
deleteBackward() → void
Deletes the character before the cursor (backspace).
deleteForward() → void
Deletes the character after the cursor (delete key).
deleteSelection() → void
Deletes the currently selected text range.
dispose() → void
Discards any resources used by the object.
inherited
insertText(String text) → void
Inserts text at the cursor position, replacing any selection first.
moveCursorLeft() → void
Moves the cursor one character to the left.
moveCursorRight() → void
Moves the cursor one character to the right.
moveCursorToEnd() → void
Moves the cursor to the end of the text.
moveCursorToStart() → void
Moves the cursor to the beginning of the text.
moveCursorWordLeft() → void
Moves the cursor one word to the left.
moveCursorWordRight() → void
Moves the cursor one word to the right.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
paste() Future<void>
Inserts clipboard content at the cursor, replacing any selection.
removeListener(dynamic listener()) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
selectAll() → void
Selects all text in the controller.
setSelection(int start, int end) → void
Sets the selection range from start to end.
toString() String
A string representation of this object.
inherited

Operators

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