Reputation: 708
Into my TextFormField, I have a onChanged call back to push the value of the variable to the database. At the moment it is a String and I do:
TextFormField(
style: TextStyle(color: Colors.white,fontSize: 13),
keyboardType: TextInputType.number,
onChanged: (value) {
variableName = value;
},
But if I change the variable String to "int" because is a number what I need to do there in onChanged call back?
Upvotes: 2
Views: 945
Reputation: 7640
If you want an int variable, you can simply convert the value in your onChanged method. It will look like this:
TextFormField(
style: TextStyle(color: Colors.white,fontSize: 13),
keyboardType: TextInputType.number,
onChanged: (value) {
variableName = int.parse(value);
},
Upvotes: 3