Baseflow / flutter_cached_network_image

Download, cache and show images in a flutter app
https://baseflow.com
2.42k stars 643 forks source link

Feature Request: Support null #314

Open esDotDev opened 4 years ago

esDotDev commented 4 years ago

In some cases, it would be nice to set the imageUrl to null, as we load in a new image.

For example:

  1. User picks image from gallery
  2. Start uploading new image to cloud
  3. While image is uploading, set imgUrl to null, causing old image to fade out.
  4. When upload completes (1-2s later), set imgUrl to new url, causing new image to fade in.

As it stands now, you have to leave the old image in place, while the new one uploads, which looks a little janky. Ideally it would just elegantly handle a null url, and fade out the current image.

renefloor commented 3 years ago

I think for the imageprovider it will be difficult to show the placeholder, so that will probably be an exception. The widget can show a placeholder when value is 'null', but than the imageprovider will behave different from the widget (placeholder vs error). I'm not fully sure if error of placeholder is better. If you know the image is 'null' than a placeholder is fine, but if you would have expected an image than an error makes more sense. I think quite some people actually also use the error widget as a placeholder.

luis901101 commented 1 year ago

According to documentation:

/// Widget displayed while the target [imageUrl] is loading.
  final PlaceholderWidgetBuilder? placeholder;

There is also another one simliar:

/// Widget displayed while the target [imageUrl] is loading.
  final ProgressIndicatorBuilder? progressIndicatorBuilder;

And finally:

/// Widget displayed while the target [imageUrl] failed loading.
  final LoadingErrorWidgetBuilder? errorWidget;

So if imageUrl == null || imageUrl!.isEmpty expected result should be errorWidget