textEditingController property Null safety

TextEditingController? textEditingController

The TextEditingController that is used for the text field.

The main purpose of this parameter is to allow the use of a separate text field located in another part of the widget tree instead of the text field built by fieldViewBuilder. For example, it may be desirable to place the text field in the AppBar and the options below in the main body.

When following this pattern, fieldViewBuilder can return SizedBox.shrink() so that nothing is drawn where the text field would normally be. A separate text field can be created elsewhere, and a FocusNode and TextEditingController can be passed both to that text field and to RawAutocomplete.

This examples shows how to create an autocomplete widget with the text field in the AppBar and the results in the main body of the app.
To create a local project with this code sample, run:
flutter create --sample=widgets.RawAutocomplete.focusNode.1 mysample

If this parameter is not null, then focusNode must also be not null.


final TextEditingController? textEditingController;