loopRequest method
Future<void>
loopRequest(
{ - bool validTest()?,
- void onRequest()?,
- int count = 3,
- Duration delay = const Duration(seconds: 10),
- bool immediately = false,
})
Implementation
Future<void> loopRequest({
bool Function()? validTest,
void Function()? onRequest,
int count = 3,
Duration delay = const Duration(seconds: 10),
bool immediately = false,
}) async {
logDebug("$runtimeType loop start");
var index = 0;
while (index < count) {
index++;
logDebug("$runtimeType loop isClosed:$isClosed");
if (validTest?.call() ?? !isClosed) {
if (index == 1 && !immediately) {
logDebug("$runtimeType loop no immediately");
} else {
logDebug("$runtimeType loop ing");
if (onRequest != null) {
onRequest.call();
} else {
onRequestData();
}
}
await delay.delay();
} else {
logDebug("$runtimeType loop break");
break;
}
}
}