fixed possible lockups on app start

This commit is contained in:
2026-09-11 12:04:32 +02:00
parent 43dfc52bc7
commit 3734d7ff2c
7 changed files with 452 additions and 173 deletions
+11
View File
@@ -0,0 +1,11 @@
/// Delay before retry number [attempt] (1-based): [base] doubled per attempt,
/// capped at [max].
Duration exponentialBackoff(
int attempt, {
Duration base = const Duration(milliseconds: 500),
Duration max = const Duration(seconds: 5),
}) {
final exponent = (attempt - 1).clamp(0, 30);
final millis = base.inMilliseconds * (1 << exponent);
return millis >= max.inMilliseconds ? max : Duration(milliseconds: millis);
}