CellEditingController class
A TextEditingController bound two-way to a ValueCell<String>.
CellEditingController is the Cell-Bound Text Adapter — the foundation under CellTextField. Writes to the controller's text update the cell; writes to the cell update the controller. The feedback loop is broken by equality guards on both directions: a controller update that mirrors the current cell value does not write back, and a cell update that mirrors the current controller text does not touch the controller.
Cursor preservation
A cell-driven update preserves the cursor offset from the end of the text. Typing at the end of a field therefore keeps the cursor at the end even when the cell echoes the same text back (for example through a debounced pipeline). A length-changing replacement moves the cursor to the clamped equivalent offset — a full replacement lands the cursor at the end, which is the natural expectation for an external write.
Lifecycle
Call dispose when the controller is no longer needed — it releases the internal cell observation. CellTextField does this for you; only manual users of cellEditingController need to.
See Also:
- cellEditingController — the factory.
- CellTextField — the widget that owns this controller's lifecycle.
- CellNotifier — the internal cell observation.
- Inheritance
-
- Object
- ChangeNotifier
- ValueNotifier<
TextEditingValue> - TextEditingController
- CellEditingController
Constructors
-
CellEditingController(ValueCell<
String> _cell) - Binds cell to this controller, seeding text from the cell's current value.
Properties
-
cell
→ ValueCell<
String> -
The cell this controller is bound to.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selection ↔ TextSelection
-
The currently selected range within text.
getter/setter pairinherited
- text ↔ String
-
The current string the user is editing.
getter/setter pairinherited
- value ↔ TextEditingValue
-
The current value stored in this notifier.
getter/setter pairinherited
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
buildTextSpan(
{required BuildContext context, TextStyle? style, required bool withComposing}) → TextSpan -
Builds TextSpan from current editing value.
inherited
-
clear(
) → void -
Set the value to empty.
inherited
-
clearComposing(
) → void -
Set the composing region to an empty range.
inherited
-
dispose(
) → void -
Discards any resources used by the object.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited