text property

  1. @override
String text
override

The current string the user is editing.

Implementation

@override
String get text => value.text;
  1. @override
void text=(String newText)
override

Setting this will notify all the listeners of this TextEditingController that they need to update (it calls notifyListeners). For this reason, this value should only be set between frames, e.g. in response to user actions, not during the build, layout, or paint phases.

This property can be set from a listener added to this TextEditingController; however, one should not also set selection in a separate statement. To change both the text and the selection change the controller's value.

Implementation

@override
set text(String newText) {
  value = value.copyWith(
    text: newText,
    selection: TextSelection.collapsed(offset: newText.length),
    composing: TextRange.empty,
  );
}