DownloadProgress.fromBytes constructor

DownloadProgress.fromBytes({
  1. required int totalBytes,
  2. required int downloadedBytes,
  3. double? speed,
})

Creates a DownloadProgress instance from bytes

Implementation

factory DownloadProgress.fromBytes({
  required int totalBytes,
  required int downloadedBytes,
  double? speed,
}) {
  final percentage =
      totalBytes > 0 ? (downloadedBytes / totalBytes) * 100 : 0.0;
  return DownloadProgress(
    totalBytes: totalBytes,
    downloadedBytes: downloadedBytes,
    percentage: percentage,
    speed: speed,
  );
}