flutter_cached_network_image icon indicating copy to clipboard operation
flutter_cached_network_image copied to clipboard

Progress returns null after 1.0

Open themartorana opened this issue 3 years ago • 2 comments

🐛 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

themartorana avatar May 21 '21 14:05 themartorana

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
              )
          ),
        );
      }
    )

Saxorman avatar Jan 11 '22 15:01 Saxorman

same error on v3.2.1

anchaoLu avatar Jun 27 '22 08:06 anchaoLu

progress is always null when running app on Desktop

daniel112 avatar Nov 23 '22 22:11 daniel112