Open HugoHeneault opened 1 year ago
With this code I have weird values coming up in progress listener:
final dl = DownloadManager(); final urls = <String>[]; for (final offlineTile in tiles) { urls.add(offlineTile.url); await dl.addDownload(offlineTile.url, offlineTile.getTilePath(tilesDir!)); } print(urls); final downloadProgress = dl.getBatchDownloadProgress(urls); downloadProgress.addListener(() { print('progress : ${downloadProgress.value}'); }); await dl.whenBatchDownloadsComplete(urls); print('whenBatchDownloadsComplete completed');
This log a few negative (and < 100) values but also the correct value everytime :
flutter: tiles downloading... flutter: Concurrent workers: 1 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/0/0/0.vector.pbf?apikey=xxx flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/1/0/0.vector.pbf?apikey=xxx flutter: File Exists flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/2/1/0.vector.pbf?apikey=xxx flutter: File Exists flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/3/2/1.vector.pbf?apikey=xxx flutter: File Exists flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/4/4/2.vector.pbf?apikey=xxx flutter: File Exists flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/5/8/5.vector.pbf?apikey=xxx flutter: File Exists flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/6/16/11.vector.pbf?apikey=xxx flutter: File Exists flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/7/33/22.vector.pbf?apikey=xxx flutter: File Exists flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/8/66/45.vector.pbf?apikey=xxx flutter: File Exists flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/9/132/91.vector.pbf?apikey=xxx flutter: File Exists flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/10/264/183.vector.pbf?apikey=xxx flutter: File Exists flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/11/528/367.vector.pbf?apikey=xxx flutter: File Exists flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/12/1057/735.vector.pbf?apikey=xxx flutter: File Exists flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/13/2114/1471.vector.pbf?apikey=xxx flutter: File Exists flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/13/2115/1471.vector.pbf?apikey=xxx flutter: [https://a.tile.thunderforest.com/thunderforest.outdoors-v2/0/0/0.vector.pbf?apikey=xxx, https://a.tile.thunderforest.com/thunderforest.outdoors-v2/1/0/0.vector.pbf?apikey=xxx, https://a.tile.thunderforest.com/thunderforest.outdoors-v2/2/1/0.vector.pbf?apikey=xxx, https://a.tile.thunderforest.com/thunderforest.outdoors-v2/3/2/1.vector.pbf?apikey=xxx, https://a.tile.thunderforest.com/thunderforest.outdoors-v2/4/4/2.vector.pbf?apikey=xxx, https://a.tile.thunderforest.com/thunderforest.outdoors-v2/5/8/5.vector.pbf?apikey=xxx, https://a.tile.thunderforest.com/thunderforest.outdoors-v2/6/16/11.vector.pbf?apikey=xxx, https://a.tile.thunderforest.com/thunderforest.outdoors-v2/7/33/22.vector.pbf?apikey=xxx, https://a.tile.thunderforest.com/thunderforest.outdoors-v2/<…> flutter: progress : -300.94736842105266 flutter: progress : 0.7368421052631579 flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/14/4229/2942.vector.pbf?apikey=xxx flutter: progress : -309.1578947368421 flutter: progress : 0.7894736842105263 flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/14/4229/2943.vector.pbf?apikey=xxx flutter: progress : -122.84210526315789 flutter: progress : -286.1578947368421 flutter: progress : -162.47368421052633 flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/14/4230/2942.vector.pbf?apikey=xxx flutter: progress : 0.8947368421052632 flutter: Concurrent workers: 2 flutter: https://a.tile.thunderforest.com/thunderforest.outdoors-v2/14/4230/2943.vector.pbf?apikey=xxx flutter: progress : -152.26315789473685 flutter: progress : 0.9473684210526315 flutter: progress : -89.15789473684211 flutter: progress : 1.0 flutter: whenBatchDownloadsComplete completed flutter: download finished
Do you have any idea ?
it seems like in getBatchDownloadProgress we should return when if (task.status.value.isCompleted) { instead of listening as it is already completed.
getBatchDownloadProgress
if (task.status.value.isCompleted) {
But I don't have more time to investigate now (client didnt ask for progress I was just trying it) :(
Thanks for your work and help!
As a workaround, I filter values < 0 :)
With this code I have weird values coming up in progress listener:
This log a few negative (and < 100) values but also the correct value everytime :
Do you have any idea ?
it seems like in
getBatchDownloadProgress
we should return whenif (task.status.value.isCompleted) {
instead of listening as it is already completed.But I don't have more time to investigate now (client didnt ask for progress I was just trying it) :(
Thanks for your work and help!