Skip to main content

Image

The Image widget allows you to display an image in your Flutter app using JSON. It supports images from multiple sources, including assets, files, and network URLs, and provides customization options such as alignment, color, width, height, and fit.

To learn more about the equivalent Flutter widgets and their properties, refer to the official Flutter documentation for Image.

Properties​

PropertyTypeDescription
srcStringThe source of the image. For example, a URL for network images, file path for file images, or asset path.
alignmentStacAlignmentThe alignment of the image within its container. Defaults to StacAlignment.center.
imageTypeStacImageTypeThe type of the image source: file, network, or asset. Defaults to StacImageType.network.
colorString?The color to blend with the image, provided in hex format (e.g., #FF0000 for red).
widthdouble?The width of the image in logical pixels.
heightdouble?The height of the image in logical pixels.
fitBoxFit?How the image should be inscribed into the space allocated during layout.

Enum: StacImageType​

ValueDescription
fileLoad the image from a local file.
networkLoad the image from a network URL.
assetLoad the image from Flutter's asset bundle.

Example JSON​

{
"type": "image",
"src": "https://example.com/image.png",
"alignment": "center",
"imageType": "network",
"color": "#FFFFFF",
"width": 200.0,
"height": 100.0,
"fit": "contain"
}