press method

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

Dispatch a pointer down 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.

The return value is a TestGesture object that can be used to continue the gesture (e.g. moving the pointer or releasing it).

See also:

  • tap, which presses and releases a pointer at the given location.
  • longPress, which presses and releases a pointer with a gap in between long enough to trigger the long-press gesture.


Future<TestGesture> press(
  finders.FinderBase<Element> finder, {
  int? pointer,
  int buttons = kPrimaryButton,
  bool warnIfMissed = true,
  PointerDeviceKind kind = PointerDeviceKind.touch,
}) {
  return TestAsyncUtils.guard<TestGesture>(() {
    return startGesture(
      getCenter(finder, warnIfMissed: warnIfMissed, callee: 'press'),
      pointer: pointer,
      buttons: buttons,
      kind: kind,