Flutter CachedNetworkImage 不会留下占位符
Flutter CachedNetworkImage doesn't leave placeholder
所以我使用 cachednetworkimage 函数从 firebase 存储中获取图像并在图像可用时显示它。但是,我还希望它在出现问题或用户尚未上传图像时显示模板。在这里我遇到了我的问题:尽管我在无法正确加载图像时收到一条错误消息,但缓存的网络图像一直显示加载动画,甚至懒得切换到错误小部件。有什么我遗漏的吗?
child: CachedNetworkImage(
imageUrl: _imageUrl,
imageBuilder: (context, imageProvider) => Container(
width: 100.0,
height: 100.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.white,
width: 2.0,
),
image: DecorationImage(
image: imageProvider,
fit: BoxFit.cover),
),
),
placeholder: (context, url) =>
CircularProgressIndicator(),
errorWidget: (context, url, error) =>
Icon(Icons.error),
fit: BoxFit.cover,
),
placeholder 覆盖 errorWidget。用
替换占位符
progressIndicatorBuilder: (context, url, progress) => LimitedBox(maxHeight: 40,maxWidth: 40, child: CircularProgressIndicator(value: progress.progress,))
所以我使用 cachednetworkimage 函数从 firebase 存储中获取图像并在图像可用时显示它。但是,我还希望它在出现问题或用户尚未上传图像时显示模板。在这里我遇到了我的问题:尽管我在无法正确加载图像时收到一条错误消息,但缓存的网络图像一直显示加载动画,甚至懒得切换到错误小部件。有什么我遗漏的吗?
child: CachedNetworkImage(
imageUrl: _imageUrl,
imageBuilder: (context, imageProvider) => Container(
width: 100.0,
height: 100.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.white,
width: 2.0,
),
image: DecorationImage(
image: imageProvider,
fit: BoxFit.cover),
),
),
placeholder: (context, url) =>
CircularProgressIndicator(),
errorWidget: (context, url, error) =>
Icon(Icons.error),
fit: BoxFit.cover,
),
placeholder 覆盖 errorWidget。用
替换占位符 progressIndicatorBuilder: (context, url, progress) => LimitedBox(maxHeight: 40,maxWidth: 40, child: CircularProgressIndicator(value: progress.progress,))