longPress method

Future<void> longPress({
  1. SettlePolicy? settlePolicy,
  2. Duration? visibleTimeout,
  3. Duration? settleTimeout,
  4. Alignment alignment = Alignment.center,
})

Waits until this finder finds at least 1 visible widget and then makes long press gesture on it.

Example:

// long presses on the first widget having Key('createAccount')
await $(#createAccount).longPress();

If the finder finds more than 1 widget, you can choose which one to make long press on:

// long presses on the third TextButton widget
await $(TextButton).at(2).longPress();

After long press gesture this method automatically calls WidgetTester.pumpAndSettle. If you want to disable this behavior, set settlePolicy to SettlePolicy.noSettle.

See also:

Implementation

Future<void> longPress({
  SettlePolicy? settlePolicy,
  Duration? visibleTimeout,
  Duration? settleTimeout,
  Alignment alignment = Alignment.center,
}) => wrapWithPatrolLog(
  action: 'longPress',
  color: AnsiCodes.yellow,
  function: () => tester.longPress(
    this,
    settlePolicy: settlePolicy,
    visibleTimeout: visibleTimeout,
    settleTimeout: settleTimeout,
    alignment: alignment,
    enablePatrolLog: false,
  ),
);