waitUntilAsync method
Implementation
Future<int> waitUntilAsync(Future<bool> Function() test,
{final int maxIterations = 1000,
final Duration step = const Duration(milliseconds: 10)}) async {
int iterations = 0;
for (; iterations < maxIterations; iterations++) {
await Future.delayed(step);
if (await test()) {
break;
}
}
if (iterations >= maxIterations) {
throw TimeoutException(
'Condition not reached within ${iterations * step.inMilliseconds}ms');
}
return iterations;
}