【发布时间】:2020-09-15 13:23:21
【问题描述】:
Center(
child: CachedNetworkImage(
imageUrl: "http:/ sosme link here",
errorWidget: (context, url, error) => Icon(Icons.error),
fadeInCurve: Curves.easeIn ,
fadeInDuration: Duration(milliseconds:1000),
fadeOutCurve: Curves.easeOut,
fadeOutDuration: Duration(milliseconds:500),
imageBuilder: (context, imageProvider) => Container(
height: 250.0,
width: 250.0,
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
),
borderRadius: BorderRadius.all(Radius.circular(10)),
color: Colors.white,
image: DecorationImage(
image: imageProvider,
fit: BoxFit.cover,
),
),
),
),
),
我的目标是从可能存在也可能不存在的 URL 加载图像。 如果 URL 不存在,则加载资产图像。 尝试在此处插入资产图像,但没有用。 正如我在想,如果加载它时出错,意味着没有找到图像或其他东西。所以我想显示一个本地图像。
有什么建议吗?
errorWidget: (context, url, error) => Icon(Icons.error),
错误,当我使用资产图像时
【问题讨论】:
标签: image flutter caching networking dart