I have declared var valueName; before my widget builder and after I set it with Firebase document value: valueName = widget.item.name; Then, i used valueName for initial value of a TextFormField and a setState in onChanged. But when i use valueName in my update to Firestore function, it load the first old value. I can't update this value.
This is my TextFormField code:
TextFormField(
initialValue: valueName,
onChanged: (input) {
setState(() {
this.valueName = input;
print(valueName);
});
},
keyboardType: TextInputType.name,
decoration: InputDecoration(
border: UnderlineInputBorder(),
filled: true,
icon: Icon(
Icons.person
),
hintText: 'Inserisci il nome',
labelText: 'Nome'
),
),