flutter textfield set text code example
Example 1: textfield set value flutter
/// You can use a [TextFormField] instead of [TextField]
/// and use the [initialValue] property. for example:
TextFormField(initialValue: "I am smart")
Example 2: edite text in flutter
Widget _editTitleTextField() { if (_isEditingText) return Center( child: TextField( onSubmitted: (newValue){ setState(() { initialText = newValue; _isEditingText =false; }); }, autofocus: true, controller: _editingController, ), ); return InkWell( onTap: () { setState(() { _isEditingText = true; }); }, child: Text( initialText, style: TextStyle( color: Colors.black, fontSize: 18.0, ), );}
Example 3: flutter text replace in a textfield
final _newValue = "New value";
_controller.value = TextEditingValue(
text: _newValue,
selection: TextSelection.fromPosition(
TextPosition(offset: _newValue.length),
),
);