I am using cached_network_image package to display images and have placeholders while being loaded. Below is the error that I have and the widget where I use CachedNetworkImage.
The argument type 'CachedNetworkImage' can't be assigned to the parameter type 'ImageProvider<Object>'
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(3),
image: DecorationImage(
image: CachedNetworkImage(
imageUrl: "https://cdn....${item.id}/${item.imageName}.jpg",
imageBuilder: (context, imageProvider) => Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider,
fit: BoxFit.cover,
),
),
),
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => Icon(Icons.error),
),
fit: BoxFit.cover,
),
),
Searched a bit and I found similar question in this Github thread and an answer that explains that CachedNetworkImage provides a callback that I can use to return image provider. I tried that example but still have that error.
https://github.com/Baseflow/flutter_cached_network_image/issues/177#issuecomment-510359079
I noticed that question in Github thread has The argument type 'CachedNetworkImage' can't be assigned to the parameter type 'ImageProvider'. error, while mine is The argument type 'CachedNetworkImage' can't be assigned to the parameter type 'ImageProvider<Object>'.
Could anyone tell me please what I am doing wrong.