TextEditingController class
Controls the state of a TextField.
Whenever the user modifies a text field with an associated TextEditingController, the text field updates model and the controller notifies its listeners.
- Inheritance
-
- Object
- ChangeNotifier
- TextEditingController
- Implemented types
Constructors
- TextEditingController({String? text, TextInputModel? model})
Properties
- canRedo → bool
-
Whether there is an undone edit available to redo.
no setter
- canUndo → bool
-
Whether there is an edit available to undo.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- model ↔ TextInputModel
-
The current TextInputModel managed by this controller.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selection ↔ TextSelection
-
The current selection.
getter/setter pair
- text ↔ String
-
The current text being edited.
getter/setter pair
- value ↔ TextEditingValue
-
The current value held by this object.
getter/setter pairoverride-getter
Methods
-
addListener(
void listener()) → void -
Register
listenerto be called when the object notifies.inherited -
clear(
) → void - Clears the text.
-
clearHistory(
) → void - Clears all undo and redo history.
-
deleteBackward(
{bool word = false, bool coalesce = false}) → bool - Deletes backward from the cursor or removes the current selection.
-
deleteForward(
{bool word = false, bool coalesce = false}) → bool - Deletes forward from the cursor or removes the current selection.
-
deleteSelection(
) → bool - Deletes the current selection.
-
dispose(
) → void -
Releases all listeners. After this call the notifier should not be used.
inherited
-
insertText(
String text, {bool replaceSelection = true, bool coalesce = false}) → void -
Inserts
textat the cursor, optionally replacing the selection. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Notify all registered listeners.
inherited
-
pushHistoryBoundary(
) → void - Starts a fresh undo step for the next edit.
-
redo(
) → bool - Reapplies the most recently undone edit state and notifies listeners.
-
removeListener(
void listener()) → void -
Remove a previously registered
listener.inherited -
replaceSelection(
String text) → void - Replaces the current selection, or inserts at the cursor if collapsed.
-
selectAll(
) → void - Selects all text.
-
throwIfDisposed(
) → void -
Throws StateError if this notifier has already been disposed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
undo(
) → bool - Restores the previous edit state and notifies listeners.
-
update(
Msg msg) → Cmd? -
Updates the model using the provided
msg.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited