waitUntilVisible method
Waits until finder
finds at least one visible widget.
Throws a WaitUntilVisibleTimeoutException if more time than specified by the timeout passed and no widgets were found.
Timeout is globally set by PatrolTester.config.visibleTimeout
. If you
want to override this global setting, set timeout
.
Implementation
Future<PatrolFinder> waitUntilVisible(
Finder finder, {
Duration? timeout,
}) {
return TestAsyncUtils.guard(() async {
final duration = timeout ?? config.visibleTimeout;
final end = tester.binding.clock.now().add(duration);
final hitTestableFinder = finder.hitTestable();
while (hitTestableFinder.evaluate().isEmpty) {
final now = tester.binding.clock.now();
if (now.isAfter(end)) {
throw WaitUntilVisibleTimeoutException(
finder: finder,
duration: duration,
);
}
await tester.pump(const Duration(milliseconds: 100));
}
return PatrolFinder(finder: hitTestableFinder, tester: this);
});
}