import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
class ImageWidget extends StatelessWidget {
final String image;
const ImageWidget({super.key, required this.image});
@override
Widget build(BuildContext context) {
final height = MediaQuery.of(context).size.height;
final theme = Theme.of(context);
return SizedBox(
height: height * 0.4,
width: double.infinity,
child: CachedNetworkImage(
imageUrl: image,
fit: BoxFit.cover,
memCacheHeight: 400,
maxHeightDiskCache: 800,
progressIndicatorBuilder: (context, url, downloadProgress) =>
Container(
color: theme.colorScheme.surfaceContainerHighest,
child: Center(
child: CircularProgressIndicator(value: downloadProgress.progress),
),
),
errorWidget: (context, url, error) {
return Container(
color: theme.colorScheme.surfaceContainerHighest,
child: Center(
child: Icon(
Icons.image_not_supported_outlined,
size: 48,
color: theme.colorScheme.onSurfaceVariant,
),
),
);
},
),
);
}
}