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.
26 lines
830 B
Dart
26 lines
830 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;
|
|
const ImageLoader({Key key, @required this.url, this.boxFit, this.color, this.alignment, this.width, this.height}) : 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) => const Icon(Icons.broken_image_rounded),
|
|
);
|
|
}
|
|
}
|