Skip to main content

Image

The C2CImage widget is a customizable image widget designed for use in Flutter applications.

It offers various features and customization options, including fade-in/out animations, error handling, and semantic labels.

Example Usage

// Normal image
const C2CImage(
size: Size(double.infinity, 250),
image: NetworkImage('https://picsum.photos/200'),
errorImage: AssetImage('assets/images/noAvatar.png'),
placeholderImage: AssetImage('assets/images/loading.png'),
)

// Circle image
const C2CImage(
size: Size.square(200),
image: NetworkImage('https://picsum.photos/200'),
errorImage: AssetImage('assets/images/noAvatar.png'),
placeholderImage: AssetImage('assets/images/loading.png'),
shape: BoxShape.circle,
)

// Show image with min/max size
const C2CImage(
constraints: BoxConstraints(
minWidth: 150,
maxWidth: 250,
minHeight: 150,
maxHeight: 250,
),
image: NetworkImage('https://picsum.photos/200'),
placeholderImage: AssetImage('assets/images/noAvatar.png'),
isShowPlaceholderWhenError: true,
)

Properties

PropertyDescriptionType
imageThe target image to display.ImageProvider?
sizeThe size of the image. Size(width, height). Default is: Size(40,40)Size?
constraintsMinimum and maximum size constraints for the image.BoxConstraints?
shapeThe shape of the image container. (rectangle or circle). Default: BoxShape.rectangleBoxShape
fitHow to inscribe the image into the allocated space. Default: BoxFit.coverBoxFit
filterQualityThe rendering quality of the image.FilterQuality
alignmentHow to align the image within its bounds.AlignmentGeometry
repeatHow to repeat the image if it doesn't cover the entire space.ImageRepeat
backgroundColorThe background color of the image container.Color?
placeholderImageImage to display while the target image is loading.ImageProvider?
placeholderImageFitHow to fit the placeholder image.BoxFit?
placeholderImageFilterQualityRendering quality of the placeholder image.FilterQuality?
placeholderImageBuilderBuilder function for the placeholder.Widget Function(BuildContext)?
isShowPlaceholderWhenErrorWhether to show the placeholder when an error occurs.bool?
errorImageImage to display if an error occurs during loading.ImageProvider?
errorImageFitHow to fit the error image.BoxFit?
errorImageFilterQualityRendering quality of the error image.FilterQuality?
errorImageBuilderBuilder function for the error image.Widget Function(BuildContext)?
isFadeEnabledEnable or disable fade-in/out animations.bool?
fadeOutDurationDuration of the fade-out animation for the placeholder image.Duration
fadeOutCurveCurve of the fade-out animation for the placeholder image.Curve
fadeInDurationDuration of the fade-in animation for the target image.Duration
fadeInCurveCurve of the fade-in animation for the target image.Curve
matchTextDirectionWhether to paint the image based on text direction.bool
excludeFromSemanticsWhether to exclude the image from semantics.bool
imageSemanticLabelA semantic description of the image.String?