简体   繁体   中英

TextFormFields in flutter

Can i use flutter's text form field to create a page similar to Instagram's 'edit profile'? When i click edit profile, my name and username is already displayed in the box and i can change it if i want to, and then save it. Currently, i am trying to use text form field to do this but i am unable to do it such that when i enter the page, my respective data is already in the box. Hence, i am unable to see my information (what i previously keyed in).

Right now, i have used a few TextEditingControllers and controllers to store my data in firebase.

Yes, when creating a text field, you need to pass in a TextEditingController. TextEditingController's have a constructor for text that you can use to set a starting value. Example Code:

TextEditingController nameController = new TextEditingController(text: username); //the controller
TextFormField( //the text field with your username already passed in
      controller: nameController,
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM