DownloadProgress.fromMap constructor

DownloadProgress.fromMap(
  1. Map<String, dynamic> map
)

Implementation

factory DownloadProgress.fromMap(Map<String, dynamic> map) {
  return DownloadProgress(
    modelId: map['modelId'] as String,
    downloadedBytes: map['downloadedBytes'] as int,
    totalBytes: map['totalBytes'] as int,
    percentage: map['percentage'] as int,
    speedMBps: (map['speedMBps'] as num).toDouble(),
    status: DownloadStatus.values.firstWhere(
      (s) => s.name == map['status'],
      orElse: () => DownloadStatus.downloading,
    ),
  );
}