flutter_cached_network_image
flutter_cached_network_image copied to clipboard
Progress returns null after 1.0
🐛 Bug Report
In progressIndicatorBuilder
the DownloadProgress
argument has progress.progress == null
moments after it returns 1.0. This causes the indicator to become indeterminate as the now-downloaded image fades into view. progress.downloaded
is also reset to 0.
Expected behavior
Download progress, once reaching 1.0, will stay at 1.0, download total will stay > 0.
Reproduction steps
// with progress value logging
return CachedNetworkImage(
imageUrl: "<SIZEABLE IMAGE URL HERE>",
progressIndicatorBuilder: (context, url, progress) {
final t = DateTime.now(). t.toIso8601String();
print("$t Progress: ${progress.progress} Downloaded: ${progress.downloaded}");
return CircularProgressIndicator.adaptive(
value: progress.progress,
);
},
errorWidget: (context, url, error) => ...
);
Sample output:
2021-05-21T11:06:46.417502 Progress: null Downloaded: 0
2021-05-21T11:06:48.272545 Progress: 0.11589180050718512 Downloaded: 4113
2021-05-21T11:06:48.305771 Progress: 0.3090448013524937 Downloaded: 10968
2021-05-21T11:06:48.342850 Progress: 0.46356720202874047 Downloaded: 16452
2021-05-21T11:06:48.375774 Progress: 0.7339814032121724 Downloaded: 26049
2021-05-21T11:06:48.409621 Progress: 0.9271344040574809 Downloaded: 32904
2021-05-21T11:06:48.435467 Progress: 1.0 Downloaded: 35490
2021-05-21T11:06:48.532975 Progress: null Downloaded: 0
Configuration
Version: 3.0.0
Platform:
- [x] :iphone: iOS
- [x] :robot: Android
Hi! I took this kind of solution to this problem:
bool successLoad = false;
return CachedNetworkImage(
imageUrl: url,
progressIndicatorBuilder: (context, url, downloadProgress) {
if (!successLoad) {
successLoad = downloadProgress.downloaded ==
downloadProgress.totalSize;
}
return Center(
child: SizedBox(
height: 32,
width: 32,
child: CircularProgressIndicator(
value: !successLoad ? downloadProgress.progress : 0
)
),
);
}
)
same error on v3.2.1
progress is always null when running app on Desktop