longPress method

Future<void> longPress(
  1. FinderBase<Element> finder,
  2. {int? pointer,
  3. int buttons = kPrimaryButton,
  4. bool warnIfMissed = true,
  5. PointerDeviceKind kind = PointerDeviceKind.touch}

Dispatch a pointer down / pointer up sequence (with a delay of kLongPressTimeout + kPressTimeout between the two events) at the center of the given widget, assuming it is exposed.

The warnIfMissed argument, if true (the default), causes a warning to be displayed on the console if the specified Finder indicates a widget and location that, were a pointer event to be sent to that location, would not actually send any events to the widget (e.g. because the widget is obscured, or the location is off-screen, or the widget is transparent to pointer events).

Set the argument to false to silence that warning if you intend to not actually hit the specified element.

For example, consider a widget that, when long-pressed, shows an overlay that obscures the original widget. A test for that widget might first long-press that widget with warnIfMissed at its default value true, then later verify that long-pressing the same location (using the same finder) has no effect (since the widget is now obscured), setting warnIfMissed to false on that second call.


Future<void> longPress(
  finders.FinderBase<Element> finder, {
  int? pointer,
  int buttons = kPrimaryButton,
  bool warnIfMissed = true,
  PointerDeviceKind kind = PointerDeviceKind.touch,
}) {
  return longPressAt(
    getCenter(finder, warnIfMissed: warnIfMissed, callee: 'longPress'),
    pointer: pointer,
    buttons: buttons,
    kind: kind,