mobile/smart_downloader
library
Enums
-
ResumeAction
-
Decision for a failed download: whether to resume, do a fresh retry, or give
up. Extracted so the resume-attempt cap (#355) is unit-testable.
Constants
-
kMaxResumeAttempts
→ const int
-
-
kResumeWatchdog
→ const Duration
-
Watchdog window after a resume: if no progress/terminal event arrives within
this, the task is presumed silently dead (#355) and the stream is closed.
Functions
-
armResumeWatchdog({required StreamController<int> progress, required void onTimeout(), Duration timeout = kResumeWatchdog})
→ Timer
-
Returns a Timer that fires
onTimeout after timeout unless cancelled.
The download loop cancels it when the next progress/status event arrives, and
wires onTimeout to close progress with a network error + cancel the
listener, so a silently-dead post-resume task can never hang forever.
-
decideFailedDownloadAction({required bool canResume, required int resumeAttempt, required int currentAttempt, required int maxRetries, required int maxResumeAttempts})
→ ResumeAction
-
Pure decision for
_handleFailedDownload. Resume is only chosen while under
maxResumeAttempts — the old code resumed unconditionally whenever
canResume, which let a repeatedly-failing resume loop forever (#355).
-
shouldConfigureForegroundNotification(bool? foreground)
→ bool
-
Whether
_ensureConfigured should register a running TaskNotification
for the given foreground setting (#356). Extracted as a pure function so
the decision is unit-testable without a FileDownloader seam: on Android,
background_downloader only calls WorkManager.setForeground() — the
thing that actually activates the foreground service — when a running
notification is configured. Setting Config.runInForeground alone is a
no-op without it.