simpler image loader!
This commit is contained in:
parent
8c988412d2
commit
64a0fca55d
|
|
@ -24,29 +24,23 @@ class SkeletonImage extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return _aspectRatioGenerator(
|
return _aspectRatioGenerator(
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: borderRadius,
|
||||||
child: CachedNetworkImage(
|
child: CachedNetworkImage(
|
||||||
|
fit: BoxFit.cover,
|
||||||
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
||||||
httpHeaders: {'Authorization': 'Bearer ${RequestService.token}'},
|
httpHeaders: {'Authorization': 'Bearer ${RequestService.token}'},
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
imageUrl: RequestHelper.baseUrl + imageUrl,
|
imageUrl: RequestHelper.baseUrl + imageUrl,
|
||||||
imageBuilder: (context, imageProvider) => ClipRRect(
|
placeholder: (context, _) => const ShimmerPlaceholder(),
|
||||||
borderRadius: borderRadius ?? DesignConfig.lowBorderRadius,
|
|
||||||
child: Image(
|
|
||||||
image: imageProvider,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
progressIndicatorBuilder: (context, url, progress) =>
|
|
||||||
ShimmerPlaceholder(
|
|
||||||
borderRadius: borderRadius,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _aspectRatioGenerator({required Widget child}) => aspectRatio == null
|
Widget _aspectRatioGenerator({required Widget child}) => aspectRatio == null
|
||||||
? SizedBox(key: ValueKey(imageUrl), child: child)
|
? child
|
||||||
: AspectRatio(
|
: AspectRatio(
|
||||||
key: ValueKey(imageUrl),
|
key: ValueKey(imageUrl),
|
||||||
aspectRatio: aspectRatio!,
|
aspectRatio: aspectRatio!,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue