Home > Software engineering >  How to Update Particular TextFormFiled value Using TextEditing Controller after fetching data from A
How to Update Particular TextFormFiled value Using TextEditing Controller after fetching data from A

Time:07-05

** TextEditingController gstController = TextEditingController( text: snapshot.data![index].gSTNo.toString());

TextFormField( controller: gstController, decoration: InputDecoration( hintText: 'Enter GST No', border: InputBorder.none, contentPadding: const EdgeInsets.all(14), ), ),**

CodePudding user response:

you can follow this example

  TextEditingController textEditingController = TextEditingController();

  TextFormField(
    controller: textEditingController,
    autovalidateMode: AutovalidateMode.onUserInteraction,
    style: TextStyle(fontSize: 15),
    decoration: FormFields.getInputDecoration('Email Id'),
  );

the after api response you can set text to textformfield using TextEditingController like this

   setState((){
      textEditingController.text = snapshot.data![index].gSTNo.toString()
   });

CodePudding user response:

add it to init State or in any SetState

gstController.value = TextEditingValue(text: "ANY TEXT");

  • Related