How do I supply an initial value to a text field?

前端 未结 10 876
南笙
南笙 2021-01-30 12:15

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?

10条回答
  •  遥遥无期
    2021-01-30 12:49

    You can use a TextFormField instead of TextField, and use the initialValue property. for example

    TextFormField(initialValue: "I am smart")
    

提交回复
热议问题