TextEditingController class
Controls editable text through an immutable TextEditingValue.
- Inheritance
-
- Object
- ChangeNotifier
- ValueNotifier<
TextEditingValue> - TextEditingController
Constructors
- TextEditingController({String text = ''})
-
Creates a controller with optional initial
text.
Properties
- col → int
-
Zero-based grapheme-cluster column of the cursor on its current line.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether at least one listener is registered.
no setterinherited
- isEmpty → bool
-
Whether the text is empty.
no setter
- line → int
-
Zero-based line index of the cursor when the selection is collapsed.
no setter
-
lines
→ List<
String> -
Lines of the current text, split on newline characters.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selection ↔ TextSelection
-
Current selection.
getter/setter pair
- selectionWithinText → bool
-
Whether both selection offsets lie within the current text
(
0 <= offset <= text.length). False for cleared (-1) selections.no setter - text ↔ String
-
Text content of the field. Setting this value also clears the current selection.
getter/setter pair
- value ↔ TextEditingValue
-
Current value.
getter/setter pairinherited
Methods
-
addListener(
VoidCallback listener) → void -
Register
listenerfor future notifications.inherited -
clear(
) → void - Clears the text and collapses the selection at offset zero.
-
deleteBack(
) → bool - Deletes the previous grapheme cluster or selected range.
-
deleteForward(
) → bool - Deletes the next grapheme cluster or selected range.
-
dispose(
) → void -
Release resources held by this object.
inherited
-
insert(
String replacement, {bool allowNewline = true}) → bool -
Inserts
replacementat the current selection. -
moveCursorDown(
) → void - Moves the collapsed cursor down one line, preserving grapheme column.
-
moveCursorLeft(
) → void - Moves the collapsed cursor left by one grapheme cluster.
-
moveCursorRight(
) → void - Moves the collapsed cursor right by one grapheme cluster.
-
moveCursorUp(
) → void - Moves the collapsed cursor up one line, preserving grapheme column.
-
moveDocumentEnd(
) → void - Moves the collapsed cursor to the end of the document.
-
moveDocumentStart(
) → void - Moves the collapsed cursor to the start of the document.
-
moveLineEnd(
) → void - Moves the collapsed cursor to the end of its current line.
-
moveLineStart(
) → void - Moves the collapsed cursor to the start of its current line.
-
newline(
) → bool - Inserts a newline at the current selection.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Notifies all registered listeners using a stable snapshot.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove one registration of
listener.inherited -
setCursor(
int line, int col) → void - Sets the collapsed selection by line and grapheme-column.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited