'How to add integer as default/initial value for TextFormField in flutter?
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
.
Solution 1:[1]
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");
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | diegoveloper |