drag method

Future<void> drag(
  1. dynamic target,
  2. Offset by, {
  3. Duration? duration,
  4. Shot? shot,
  5. Settle? settle,
})

Drags target by by — a swipe, a dismiss, a slider, a sheet pulled down. Negative dy moves the finger up the screen, the touch convention flutter_test itself uses.

duration spreads the same travel over that much of the clock, which is how a drag says anything at all about velocity.

Without it the finger moves in one jump, so the velocity tracker sees the whole distance in no time and reports none: the list stops dead where the finger stopped, and no offset will make it overscroll. Right for a dismiss or a slider, and the reason a fling was not previously expressible. Measured on a 200-row list: Offset(0, -300) bare lands at exactly 300, over a second it carries to ~324, and over 300ms — the same distance at three times the speed — it flies past 450.

On a desktop device the drag is the mouse's, as every press there is, and a mouse drag does not move a list — not on a desktop, and so not here: Flutter's default scroll behavior leaves the mouse out of the devices that drag one. scroll turns the wheel, and scrollTo walks a list wherever the scenario is staged.

Implementation

Future<void> drag(
  dynamic target,
  Offset by, {
  Duration? duration,
  Shot? shot,
  Settle? settle,
}) => _step(
  shot,
  settle,
  () async {
    var finder = await _resolve(target, 'drag');
    var at = _aimFor(target, finder, by: by);
    await _approach('drag');
    await _dragFrom(at, by, duration);
  },
  verb: 'drag',
  target: describeTarget(target),
);