getProgress method

Future<double> getProgress(
  1. String url
)

Get download progress (0.0 to 1.0).

Implementation

Future<double> getProgress(String url) async {
  final meta = await CacheMetadataStore.get(url);
  if (meta == null) return 0.0;
  if (meta.isComplete) return 1.0;
  if (meta.totalBytes == null || meta.totalBytes == 0) return 0.0;
  return meta.downloadedBytes / meta.totalBytes!;
}