49 lines
1.4 KiB
Dart
49 lines
1.4 KiB
Dart
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:didvan/config/design_config.dart';
|
|
import 'package:didvan/config/theme_data.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:skeleton_text/skeleton_text.dart';
|
|
|
|
class SkeletonImage extends StatelessWidget {
|
|
final String imageUrl;
|
|
final double width;
|
|
final double height;
|
|
final BorderRadius? borderRadius;
|
|
const SkeletonImage({
|
|
Key? key,
|
|
required this.imageUrl,
|
|
required this.width,
|
|
required this.height,
|
|
this.borderRadius,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return CachedNetworkImage(
|
|
width: width,
|
|
height: height,
|
|
imageUrl: imageUrl,
|
|
imageBuilder: (context, imageProvider) => Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: borderRadius ?? DesignConfig.lowBorderRadius,
|
|
image: DecorationImage(
|
|
image: imageProvider,
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
),
|
|
progressIndicatorBuilder: (context, url, progress) => SkeletonAnimation(
|
|
shimmerColor: Theme.of(context).colorScheme.border,
|
|
borderRadius: borderRadius ?? DesignConfig.lowBorderRadius,
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(context).colorScheme.disabledBackground,
|
|
),
|
|
height: height,
|
|
width: width,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|