|
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:flutter/material.dart';
- import 'package:qadirneyriz/config/config.dart';
-
- class CustomImage extends StatelessWidget {
- final String? image;
- final double? height;
- final double? width;
- final BoxFit? boxFit;
- final bool logo;
- final double borderRadius; // Border radius
-
- const CustomImage({
- super.key,
- required this.image,
- this.height,
- this.width,
- this.logo = false,
- this.boxFit = BoxFit.cover,
- this.borderRadius = 10.0, // Default border radius
- });
-
- @override
- Widget build(BuildContext context) {
- Widget imageWidget;
-
- if (image != null && image != '') {
- imageWidget = CachedNetworkImage(
- imageUrl: logo ? '$image' : '${config.network.baseUrl}$image',
- width: width,
- height: height,
- fit: boxFit,
- errorWidget: (_, __, ___) => Image.asset(
- "assets/images/placeholder.png",
- width: width,
- height: height,
- fit: boxFit,
- ),
- placeholder: (_, __) => Image.asset(
- "assets/images/placeholder.png",
- width: width,
- height: height,
- fit: boxFit,
- ),
- );
- } else {
- imageWidget = Image.asset(
- 'assets/images/placeholder.png',
- width: width,
- height: height,
- fit: boxFit,
- );
- }
-
- return ClipRRect(
- borderRadius: BorderRadius.circular(borderRadius),
- child: imageWidget,
- );
- }
- }
|