4
await tester.enterText(mySearchField, 'my search text');
await tester.showKeyboard(mySearchField);
await tester.sendKeyDownEvent(LogicalKeyboardKey.enter);

// do something to wait for 2 seconds
await tester.pumpAndSettle();
await Future.delayed(const Duration(seconds: 10), () {});

I'am trying to hit the done/enter/submit button on the virtual keyboard after enter a text in a search field..

how to do that, and how to wait for the result (async request)...

Maurice Raguse
  • 4,437
  • 2
  • 29
  • 46
  • any solutoion ...same i am looking for "await tester.sendKeyDownEvent(LogicalKeyboardKey.backspace);" operation to happen? – Rajesh Patil Jan 30 '22 at 09:37

1 Answers1

1
await simulateKeyDownEvent(LogicalKeyboardKey.accept);
Maurice Raguse
  • 4,437
  • 2
  • 29
  • 46
  • 2
    Welcome to Stack Overflow! On Stack Overflow, the **how** is important, but a great part of the quality level of the site comes from the fact that people go to great lengths to explain the **why**. While a _code-only_ answer get the person who asked the question past whatever hurdle they might be facing, it doesn't do them or future visitors much good in the long run. See [Is there any benefit in code-only answers?](https://meta.stackexchange.com/a/148274/183937) – Steve Mar 23 '22 at 12:40
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 23 '22 at 14:02