skip to Main Content
    late final TextEditingController _weight = TextEditingController()
  late final TextEditingController _height = TextEditingController()

For example, for these two TextEditingControllers, I want to collect the values ​​entered by the user and print them in Text. How do I code this?

2

Answers


  1. You access the text by checking the text property. In your example, e.g.:

    _weight.text
    
    Login or Signup to reply.
  2. You can try to parse text property like this:

    final _weightValue = double.tryParse(_weight.text);
    final _heightValue = double.tryParse(_height.text);
    

    I suggest you force keyboard to insert only numbers with:

    keyboardType: TextInputType.number
    

    in your TextField

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search