'Flutter integration_test: How to simulate keyboard action to clear text from TextField()?

Implementing some integration_test for flutter-web application wherein I'm trying to simulate keyboard action to clear the content of the TextField(). Like we have for "Done" like: await tester.testTextInput.receiveAction(TextInputAction.done);

Any idea how to do that?



Solution 1:[1]

You can simulate keyboard presses in your test like this:

await simulateKeyDownEvent(LogicalKeyboardKey.backspace);

https://api.flutter.dev/flutter/flutter_test/simulateKeyDownEvent.html

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 Er1