This will work
TextEditingController _controller = new TextEditingController(text:"this works");
but this does not
TextEditingController _controller = new TextEditingController(text:123);
It shows this error:
The argument type 'int' can't be assigned to the parameter type 'String'.
But I’m not able to change the type to int for TextFormField
.
TextEditingController
only accepts String
, so you have to convert your number to String
.
TextEditingController _controller = new TextEditingController(text:123.toString());
or
TextEditingController _controller = new TextEditingController(text:"123");