getRetryAfter method Null safety
- Duration? retryAfter
Gives back the duration suggested by the API or a Duration based on the number of attempts if no retry headers were provided.
Implementation
Duration getRetryAfter(Duration? retryAfter) {
var usedDuration = retryAfter ?? Duration(milliseconds: 0);
if (retryAfter == null) {
switch (attempts) {
case 0:
case 1:
usedDuration = Duration(milliseconds: 0);
break;
case 2:
usedDuration = Duration(milliseconds: 100);
break;
case 3:
usedDuration = Duration(seconds: 2);
break;
default:
usedDuration = Duration(seconds: 10);
}
}
return usedDuration;
}