How to close Dialog using FlutterDriver
The key that is commonly used for modals in Flutter is ModalBarrier
, which is why the following should do the trick:
await driver.tap(find.byType('ModalBarrier'));
This will work as long as barrierDismissible
is set to true
.
Essentially, when tapping away a dialog in Flutter, you are tapping on the modal barrier, which is why above code works.
Thanks to John Muchow for finding out.