62 lines
1.5 KiB
Dart
62 lines
1.5 KiB
Dart
|
|
part of 'image.dart';
|
||
|
|
|
||
|
|
class AppNetworkImage extends StatelessWidget {
|
||
|
|
final String? url;
|
||
|
|
final double? height;
|
||
|
|
final double? width;
|
||
|
|
final double? borderRadius;
|
||
|
|
final BoxFit? fit;
|
||
|
|
final bool? isCanZoom;
|
||
|
|
final VoidCallback? onTap;
|
||
|
|
|
||
|
|
const AppNetworkImage({
|
||
|
|
super.key,
|
||
|
|
this.url,
|
||
|
|
this.height,
|
||
|
|
this.width,
|
||
|
|
this.borderRadius = 0,
|
||
|
|
this.fit = BoxFit.cover,
|
||
|
|
this.isCanZoom = false,
|
||
|
|
this.onTap,
|
||
|
|
});
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
Widget customPhoto(
|
||
|
|
double? heightx,
|
||
|
|
double? widthx,
|
||
|
|
BoxFit? fitx,
|
||
|
|
double? radius,
|
||
|
|
) {
|
||
|
|
return CachedNetworkImage(
|
||
|
|
imageUrl: url.toString(),
|
||
|
|
placeholder: (context, url) => Shimmer.fromColors(
|
||
|
|
baseColor: Colors.grey[300]!,
|
||
|
|
highlightColor: Colors.grey[100]!,
|
||
|
|
child: Container(
|
||
|
|
height: height,
|
||
|
|
width: width,
|
||
|
|
decoration: BoxDecoration(
|
||
|
|
color: Colors.grey.shade300,
|
||
|
|
borderRadius: BorderRadius.circular(radius ?? 0),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
errorWidget: (context, url, error) =>
|
||
|
|
ImagePlaceholder(height: height, width: width),
|
||
|
|
height: heightx,
|
||
|
|
width: widthx,
|
||
|
|
fit: fitx,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
return GestureDetector(
|
||
|
|
onTap: onTap,
|
||
|
|
child: ClipRRect(
|
||
|
|
borderRadius: BorderRadius.circular(borderRadius!),
|
||
|
|
child: customPhoto(height, width, BoxFit.fill, borderRadius),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|