flutterflutter-integration-test

How to clear the entered text in flutter integration test?


In flutter integration test, we generally enter the text by

await tester.enterText(find.byKey(ValueKey(key)), value);

But can anybody help me in clearing the entered text?


Solution

  • According to documentation:

    Give the text input widget specified by finder the focus and replace its content with text...

    https://api.flutter.dev/flutter/flutter_test/WidgetTester/enterText.html

    you should be able to clear input text with:

    await tester.enterText(find.byKey(ValueKey(key)), '');