You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
932 B
Dart
28 lines
932 B
Dart
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class ImageLoader extends StatelessWidget {
|
|
final String? url;
|
|
final BoxFit? boxFit;
|
|
final Color? color;
|
|
final Alignment? alignment;
|
|
final double? width;
|
|
final double? height;
|
|
final bool showDefaultIcon;
|
|
|
|
const ImageLoader({Key? key, required this.url, this.boxFit, this.color, this.alignment, this.width, this.height, this.showDefaultIcon = false}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return CachedNetworkImage(
|
|
imageUrl: url ?? "",
|
|
fit: boxFit ?? BoxFit.cover,
|
|
alignment: Alignment.center,
|
|
width: width,
|
|
height: height,
|
|
placeholder: (context, url) => const Center(child: CircularProgressIndicator()),
|
|
errorWidget: (context, url, error) => Icon(showDefaultIcon ? Icons.image_outlined : Icons.broken_image_rounded),
|
|
);
|
|
}
|
|
}
|