Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

60 linhas
1.4 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 double borderRadius; // Border radius
  10. const CustomImage({
  11. super.key,
  12. required this.image,
  13. this.height,
  14. this.width,
  15. this.boxFit = BoxFit.cover,
  16. this.borderRadius = 10.0, // Default border radius
  17. });
  18. @override
  19. Widget build(BuildContext context) {
  20. Widget imageWidget;
  21. if (image != null && image != '') {
  22. imageWidget = CachedNetworkImage(
  23. imageUrl: '${config.network.baseUrl}$image',
  24. width: width,
  25. height: height,
  26. fit: boxFit,
  27. errorWidget: (_, __, ___) => Image.asset(
  28. "assets/images/placeholder.png",
  29. width: width,
  30. height: height,
  31. fit: boxFit,
  32. ),
  33. placeholder: (_, __) => Image.asset(
  34. "assets/images/placeholder.png",
  35. width: width,
  36. height: height,
  37. fit: boxFit,
  38. ),
  39. );
  40. } else {
  41. imageWidget = Image.asset(
  42. 'assets/images/placeholder.png',
  43. width: width,
  44. height: height,
  45. fit: boxFit,
  46. );
  47. }
  48. return ClipRRect(
  49. borderRadius: BorderRadius.circular(borderRadius),
  50. child: imageWidget,
  51. );
  52. }
  53. }