buildFutureBuilderImage method
Widget
buildFutureBuilderImage(
)
Implementation
Widget buildFutureBuilderImage() {
return FutureBuilder(
future: Future.delayed(imageLoadingDelay),
builder: (context, asyncSnapshot) {
return CachedNetworkImage(
imageUrl: imagePath ?? defaultImage,
imageBuilder: (context, provider) {
return Container(
height: height,
width: width,
decoration: BoxDecoration(
image: DecorationImage(
image: provider,
fit: fit,
),
),
);
},
progressIndicatorBuilder: (context, url, downloadProgress) {
double progress = downloadProgress.progress != null && downloadProgress.progress! > 0.0 && downloadProgress.progress! < 1.0? downloadProgress.progress! : 0.0;
return Center(
child: CircleAvatar(
backgroundColor: loadingBgColor,
child: Stack(
alignment: Alignment.center,
children: [
SizedBox(
height: height,
width: width,
child: CircularProgressIndicator(
value: progress,
strokeWidth: 4,
color: loadingColor,
),
),
Txt('${(progress * 100).toStringAsFixed(0)}%', fontSize: 12, textColor: Clr.colorPrimary),
],
),
),
);
},
errorWidget: (context, url, error) => errorWidget??Container(
height: height,
width: width,
decoration: pBoxDecoration(
borderRadius: borderRadius ??
BorderRadius.circular(radius ?? Siz.defaultRadius),
),
child: Image.asset(defaultImage, width: width, height: height,fit: fit,),
),
);
}
);
}