imageWidgetBuilder method
Returns the image widget for the given index
.
Implementation
Widget imageWidgetBuilder(BuildContext context, int index) {
return Image(
image: imageBuilder(context, index),
frameBuilder: (BuildContext context, Widget child, int? frame,
bool wasSynchronouslyLoaded) {
if (wasSynchronouslyLoaded) {
return child;
}
return AnimatedOpacity(
opacity: frame == null ? 0 : 1,
duration: animationDuration,
curve: animationCurve,
child: child,
);
},
loadingBuilder: (BuildContext context, Widget child,
ImageChunkEvent? loadingProgress) {
bool shouldShowLoading = loadingProgress != null;
return IndexedStack(
index: shouldShowLoading ? 1 : 0,
alignment: Alignment.center,
children: <Widget>[
child,
progressIndicatorWidgetBuilder(
context,
index,
value: loadingProgress?.expectedTotalBytes != null
? loadingProgress!.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes!
: shouldShowLoading
? null
: 0.0,
),
],
);
},
errorBuilder: (context, error, stackTrace) {
return errorWidgetBuilder(context, index, error, stackTrace);
},
);
}