dragUntilVisible method Null safety

Future<void> dragUntilVisible(
  1. Finder finder,
  2. Finder 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(
  Finder finder,
  Finder 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));
  });
}