dimanche 17 novembre 2019

Proper way to close dialog in Flutter test

Flutter's WidgetTester has a pageBack() method for popping the route stack. When I open a page as a fullscreen dialog using MaterialPageRoute's fullscreenDialog property, the pageBack() method does not work ("One back button expected on screen"). I can't find an alternative method for the job.

What is the standard way to cancel/close a dialog in a Flutter test?

I am able to close the dialog as follows:

await tester.tap(find.byIcon(Icons.close));

But then I could have instead done a pageBack() as follows:

await tester.tap(find.byIcon(Icons.arrow_back));

Why have the pageBack() method but no equivalent for closing a dialog?

I have not yet written my Cupertino UI yet. Will that test need to look for a different icon?

See also a similar problem I had with selecting the overflow menu.

Aucun commentaire:

Enregistrer un commentaire