dragUntilVisible method

Future<void> dragUntilVisible(
  1. FinderBase<Element> finder,
  2. FinderBase<Element> view,
  3. Offset moveStep, {
  4. int maxIteration = 50,
  5. Duration duration = const Duration(milliseconds: 50),
})

Repeatedly drags view by moveStep until finder is visible.

Between each drag, advances the clock by duration.

Throws a StateError if finder is not found after maxIteration drags.

See also:

Implementation

Future<void> dragUntilVisible(
  finders.FinderBase<Element> finder,
  finders.FinderBase<Element> view,
  Offset moveStep, {
    int maxIteration = 50,
    Duration duration = const Duration(milliseconds: 50),
}) {
  return TestAsyncUtils.guard<void>(() async {
    while (maxIteration > 0 && finder.evaluate().isEmpty) {
      await drag(view, moveStep);
      await pump(duration);
      maxIteration -= 1;
    }
    await Scrollable.ensureVisible(element(finder));
  });
}