Skip to content
This repository has been archived by the owner on Sep 22, 2024. It is now read-only.

Commit

Permalink
refactor: simplify downloading progress calculating
Browse files Browse the repository at this point in the history
  • Loading branch information
iamalper committed Sep 23, 2023
1 parent c4e8bb2 commit 61f44a8
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/classes/receiver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,10 @@ class Receiver {
file = File(join((await _tempDir).path, filename));
file = _generateFileName(file, await _tempDir);
}
final totalBytesPer100 = request.contentLength! / 100;
int downloadedBytesto100 = 0;
final totalLengh = request.contentLength!;
await for (var bytes in mime) {
file.writeAsBytesSync(bytes, mode: FileMode.writeOnly);

downloadedBytesto100 += bytes.length;
if (downloadedBytesto100 >= totalBytesPer100) {
downloadAnimC?.value += 0.01;
downloadedBytesto100 - totalBytesPer100;
}
downloadAnimC?.value += bytes.length / totalLengh;
}
final dbFile = DbFile(
name: filename,
Expand Down

0 comments on commit 61f44a8

Please sign in to comment.