Thomas Frick
Thomas Frick

Reputation: 189

flutter integration test with FlutterDrive how to do a long press

I am trying to do a long-press with flutter drive integration test.

using

await driver.tap(longPressButtonFinder);

does not help, is there something better than that?

Upvotes: 3

Views: 1541

Answers (2)

Edman
Edman

Reputation: 5605

Update

The longPress method has been added to the WidgetTester class

Original

FlutterDriver doesn't seem to have this method out of the box.

A workaround is to scroll with a 0 delta. That will lead the driver to do what effectively is a long press.

await driver.scroll(target, 0, 0, Duration(milliseconds: 400));

Upvotes: 13

Kaan
Kaan

Reputation: 33

Starting with Flutter 2 there is the following method available within WidgetTester class.

longPress

This is more explained in the above link.

Upvotes: 1

Related Questions