Provide An Initial Value To A TextField Widget in Flutter

When Using TextEditingController

If you use TextEditingController, set its text field to the desired value

TextEditingController myController = TextEditingController()..text = 'Your initial value';

  controller: myController

When Not Using TextEditingController

If you are not using the TextEditingContller, use the initialValue field directly from the TextField widget:

  initialValue: "I am smart"

Subscribe to My Newsletter

The latest programming-related news, articles and resources - sent to your inbox monthly. Unsubscribe anytime.