Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tap() in widget test showing warning in flutter

await widgetTester.tap(find.byType(ElevatedButton));

shows warning : Maybe the widget is actually off-screen, or another widget is obscuring it, or the widget cannot receive pointer events.

like image 614
Arun Kenjila Avatar asked Mar 22 '21 06:03

Arun Kenjila


People also ask

How do you test tap in flutter?

This involves three steps: Tap the add button using the tap() method. Rebuild the widget after the state has changed using the pump() method. Ensure that the list item appears on screen.

How do I know if a widget is visible in flutter?

Check if the widget is currently visible using bool isVisible() .

What is pump widget in flutter?

pumpAndSettle method Null safetyRepeatedly calls pump with the given duration until there are no longer any frames scheduled. This will call pump at least once, even if no frames are scheduled when the function is called, to flush any pending microtasks which may themselves schedule a frame.


1 Answers

Try this:

await widgetTester.ensureVisible(find.byType(ElevatedButton));
await widgetTester.pumpAndSettle();
await widgetTester.tap(find.byType(ElevatedButton));
like image 65
Alireza Avatar answered Oct 23 '22 08:10

Alireza