I get this error when try to get an integer from TextFormFeild
. I have used this widget many times but I did not get this error anytime. Does anybody know what it exactly means?
It will be a great help. The following is just a part of entire (1084 lines)code where I feel the error could be:
(Also I have initialized the controller:'bowlerIndexController = new TextEditingController(text: "");'
:/)....
void changeBowler(BuildContext context) {
showDialog(
context: context,
builder: (context) {
return new SimpleDialog(
title: new Text("Who is bowling next?",
style:
new TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold)),
children: <Widget>[
new Column(
children: List<Widget>.generate(teamBowling.length, (index) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: new Row(
children: <Widget>[
new Padding(
padding: new EdgeInsets.all(2.0),
child: new Text(
(index + 1).toString(),
style: new TextStyle(fontSize: 15.0),
),
),
new Text(teamBowling[index].player["Name"],
style: new TextStyle(
fontSize: 18.0, fontWeight: FontWeight.bold))
],
),
);
}),
),
new TextFormField(
keyboardType: new TextInputType.numberWithOptions(
signed: false, decimal: false),
decoration: new InputDecoration(
hintText: "Enter the bowler's corresponding number"),
controller: bowlerIndexController,
),
new RaisedButton(
child: new Text(
"DONE",
style: new TextStyle(color: Colors.black),
),
onPressed: () {
int a =
int.parse(bowlerIndexController.text.toString()) - 2;
if (a >= 0 && a < teamBowling.length) {
bowlerIndex = int.parse(bowlerIndexController.toString());
Navigator.pop(context);
}
})
],
);
});
}
The mistake was stupid. 🤷♀️ I did not convert the controller to text. I directly did from controller ==> String. I am keeping this question just in case anybody else has a similar query. 😜
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With