-3

how to store a value from textfield as int so I can use it with operator for calculation?

2 Answers2

0

If you have something like this :

TextEditingController textFieldValue= TextEditingController();

//[...]


TextFormField(
    controller: textFieldValue,
    decoration: const InputDecoration(
        labelText: "Enter an integer :"
    ),
    validator: (value) {
        if (value == null || value.isEmpty) {
            return 'Enter valid data';
        }
        return null;
    },
),

you can use the value with :

var integerFromTextfield = int.parse(textFieldValue.text);
Neo
  • 525
  • 3
  • 17
-1
int value=int.parse(textFieldController.text);
Neo
  • 525
  • 3
  • 17
  • Please read [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer). While this code block may answer the OP's question, this answer would be much more useful if you explain how this code is different from the code in the question, what you've changed, why you've changed it and why that solves the problem without introducing others. – Saeed Zhiany Jun 27 '22 at 07:48