flutter 图片加载

深陷在flutter_cached_network_image各种版本之间的bug与功能缺失的泥塘不久后
老夫痛定思痛,换。
于是,符合我国国情的,短小精悍的extended_image映入了我的眼中,作者地址:
https://github.com/fluttercandies/extended_image
extended_image实现了类似Android 原生glide的缓存策略
完好而强大的处理了加载状态
非常值得一用,记得star哦亲
基本使用方式
1 : 需注意 如果你 path_provider与作者的版本不一 记得修改
2 :ExtendedImage.network(imageUrl,//url必传
width: width,
height: height,
fit: fit,
color: color ?? null, loadStateChanged: (ExtendedImageState state) {
if (state.extendedImageLoadState == LoadState.loading) {
print(“LoadState.loading”);
return placeHolderWidget;//加载时占位布局
}
if (state.extendedImageLoadState == LoadState.failed) {
return errorWidget ?? Image.asset(“assets/placeholder.png”);////加载失败布局
}
});

猜你喜欢

转载自blog.csdn.net/qq_36071410/article/details/88645017
今日推荐