No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

61 líneas
1.5 KiB

  1. import 'package:cached_network_image/cached_network_image.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:qadirneyriz/config/config.dart';
  4. class CustomImage extends StatelessWidget {
  5. final String? image;
  6. final double? height;
  7. final double? width;
  8. final BoxFit? boxFit;
  9. final bool logo;
  10. final double borderRadius; // Border radius
  11. const CustomImage({
  12. super.key,
  13. required this.image,
  14. this.height,
  15. this.width,
  16. this.logo = false,
  17. this.boxFit = BoxFit.cover,
  18. this.borderRadius = 10.0, // Default border radius
  19. });
  20. @override
  21. Widget build(BuildContext context) {
  22. Widget imageWidget;
  23. if (image != null && image != '') {
  24. imageWidget = CachedNetworkImage(
  25. imageUrl: logo ? '$image' : '${config.network.baseUrl}$image',
  26. width: width,
  27. height: height,
  28. fit: boxFit,
  29. errorWidget: (_, __, ___) => Image.asset(
  30. "assets/images/placeholder.png",
  31. width: width,
  32. height: height,
  33. fit: boxFit,
  34. ),
  35. placeholder: (_, __) => Image.asset(
  36. "assets/images/placeholder.png",
  37. width: width,
  38. height: height,
  39. fit: boxFit,
  40. ),
  41. );
  42. } else {
  43. imageWidget = Image.asset(
  44. 'assets/images/placeholder.png',
  45. width: width,
  46. height: height,
  47. fit: boxFit,
  48. );
  49. }
  50. return ClipRRect(
  51. borderRadius: BorderRadius.circular(borderRadius),
  52. child: imageWidget,
  53. );
  54. }
  55. }