opt update down progress

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-12-03 19:05:00 +08:00
parent 196ddf3f5f
commit c42468e2c8

View File

@@ -13,6 +13,7 @@ class DownloadManager {
final void Function([Object? error]) onDone;
DownloadStatus _status = DownloadStatus.downloading;
DownloadStatus get status => _status;
final _cancelToken = CancelToken();
late Future<void> task;
@@ -78,11 +79,16 @@ class DownloadManager {
onReceiveProgress?.call(0, contentLength);
}
int? last;
try {
await for (final chunk in data.stream) {
sink.add(chunk);
received += chunk.length;
onReceiveProgress?.call(received, contentLength);
final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
if (last != now) {
last = now;
onReceiveProgress?.call(received, contentLength);
}
}
await sink.close();
_status = DownloadStatus.completed;