0

In flutter integration test, i want to get the text entered in TextField widget.

Here is the development code looks like:

enter image description here

,

Here is the integration test code I written to get the text of it

enter image description here

,

Its printing the hole widget tree data, but i want to only get the value entered in TextField

Any helps highly appreciated!

Jagadeesh
  • 358
  • 5
  • 17

1 Answers1

0

Just use a Test controller. Create your TextEditingController as a global variable in your State class and set it into your TextField widget.

final TextEditingController monthlyHousingPayment = TextEditingController();



 @override
  void dispose() {
    // Clean up the controller when the widget is disposed.
    monthlyHousingPayment.dispose();
    super.dispose();
  }

    TextField(
  controller: emailController,
  obscureText: true,
  textAlign: TextAlign.left,
  decoration: InputDecoration(
    border: InputBorder.none,
    hintText: 'PLEASE ENTER YOUR EMAIL',
    hintStyle: TextStyle(color: Colors.grey),
  ),
)

you can get the value using :

monthlyHousingPayment.text