retryUntil function
Calls predicate up to maxAttempts times, returning true as soon as it
succeeds, or false if every attempt fails.
Example:
retryUntil(() => randomBool(), maxAttempts: 5);
Implementation
bool retryUntil(bool Function() predicate, {int maxAttempts = 10}) {
for (int i = 0; i < maxAttempts; i++) {
if (predicate()) return true;
}
return false;
}