Search code examples
flutterdartflutter-web

Flutter integration_test: How to simulate mouse operation like right/scroll/left clicks?


Implementing some integration_test for flutter-web application wherein I'm trying to simulate mouse operation like right/scroll/left clicks?

After much googling tried with the below code, seems to be like TestPointer doesn't have click operation:

final TestPointer testPointer = TestPointer(1, PointerDeviceKind.mouse); 
  await tester.sendEventToBinding(testPointer.hover());

Please correct me if am missing something or any suggestion or docs reference would help?


Solution

  • Right Click can be solved by passing the Secondary Mouse Button value to tap.

    int button = rightButton ? kSecondaryMouseButton : kPrimaryButton;

    await tester.tap(place, buttons: button);