I\'d like to supply an initial value to a text field and redraw it with an empty value to clear the text. What\'s the best approach to do that with Flutter\'s APIs?
If you are using TextEditingController then set the text to it, like below
TextEditingController _controller = new TextEditingController();
_controller.text = 'your initial text';
final your_text_name = TextFormField(
autofocus: false,
controller: _controller,
decoration: InputDecoration(
hintText: 'Hint Value',
),
);
and if you are not using any TextEditingController then you can directly use initialValue like below
final last_name = TextFormField(
autofocus: false,
initialValue: 'your initial text',
decoration: InputDecoration(
hintText: 'Last Name',
),
);
For more reference TextEditingController