'How can I test that a AlertDialog appeared?
Hello I have a window with a button that should open an AlertDialog. How can I build a test that tells me that the alert opened?
var button = find.byKey(KEY_ADD_WALLET);
await tester.tap(button);
expect(... ??? ...)
Solution 1:[1]
I found the answer myself:
var button = find.byKey(KEY_ADD_WALLET);
await tester.tap(button);
await tester.pumpAndSettle();
expect(find.byType(Dialog), findsOneWidget);
The magic is calling tester.pumpAndSettle();
A more specific test could be:
expect(find.descendant(of: find.byType(Dialog), matching: find.text("Add public wallet")),findsOneWidget);
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 | Ste |
