Skip to content

Image

Renders a raster image, adapting to what the surface can do.

Learn more: Loading data

Import: package:fleury/fleury.dart, or package:fleury/fleury_core.dart in browser code.

Image.bytes(logoBytes, fit: ImageFit.contain)
// Image.file(...) needs dart:io — use bytes/decoded in embeds

On surfaces that support inline pixels (MediaQuery’s SurfaceCapabilities.images reports placements — a Kitty/iTerm2/ Sixel terminal, or a browser surface) the widget records a neutral image placement and the presenter renders true pixels. Everywhere else it paints glyph art: each terminal cell holds two vertical “pixels”, the top half drawn via the foreground of ▀, the bottom half via its background — 24-bit color per half-cell on truecolor terminals. With 256 or 16 colors, the widget reduces the image’s colors itself, dithering to smooth the result; with no color support it draws without color. Both paths resolve fit through the same core geometry, so a letterbox lands on the same cells either way.

Decoding is synchronous and cached on the ImageSource; the widget itself is cheap to rebuild. For HTTP or other async sources, decode upstream and pass via ImageSource.decoded.

ParameterTypeDefaultDescription
source:ImageSourcerequiredPixel source decoded when the widget is mounted or replaced.
fit:ImageFitImageFit.containScaling and cropping policy within the widget’s allotted cell area.
glyph:ImageGlyphImageGlyph.halfBlockSymbol palette for the glyph-art fallback. ImageGlyph.halfBlock is the conservative default; ImageGlyph.quarterBlock roughly doubles horizontal resolution at the cost of more font-glyph reliance. Ignored when the surface renders inline pixels (SurfaceCapabilities.images reports placements) — that path is already pixel-perfect and needs no palette.
backgroundColor:Color?—For the glyph-art fallback, semitransparent pixels (0 < α < 255) are alpha-composited against this color when non-null: out = α · src + (1−α) · bg. Fully-transparent pixels are also flattened to backgroundColor. True-pixel placements retain the source alpha. More
semanticLabel:String?—Describes the image for screen readers, agents, tests, and inspectors. More
  • backgroundColor: When null, cells whose pixels are all transparent stay empty (showing the terminal’s own background), a transparent half of a half-block cell shows the background too, and semitransparent pixels are weighted by their α in the area average — readable but doesn’t match what designers expect from a compositor. Provide backgroundColor (typically the surrounding container’s color) when transparent PNGs need crisp edges against a known surface.
  • semanticLabel: Leave null for decorative images. Capability and fallback state is still exposed so diagnostics can explain how the image rendered.

Shorthand for Image(source: ImageSource.file(path)) — the common path for asset-style usage. Mirrors Flutter’s Image.file(File(path)).

Browser hosts should use Image.bytes or Image.decoded instead.

ParameterTypeDefaultDescription
pathStringrequiredFile path read by the synchronously decoded, shared file cache.
fit:ImageFitImageFit.containScaling and cropping policy within the widget’s allotted cell area.
glyph:ImageGlyphImageGlyph.halfBlockSymbol palette for the glyph-art fallback. ImageGlyph.halfBlock is the conservative default; ImageGlyph.quarterBlock roughly doubles horizontal resolution at the cost of more font-glyph reliance. Ignored when the surface renders inline pixels (SurfaceCapabilities.images reports placements) — that path is already pixel-perfect and needs no palette.
backgroundColor:Color?—For the glyph-art fallback, semitransparent pixels (0 < α < 255) are alpha-composited against this color when non-null: out = α · src + (1−α) · bg. Fully-transparent pixels are also flattened to backgroundColor. True-pixel placements retain the source alpha. More
semanticLabel:String?—Describes the image for screen readers, agents, tests, and inspectors. More

Shorthand for Image(source: ImageSource.bytes(bytes)).

ParameterTypeDefaultDescription
bytesUint8ListrequiredEncoded image bytes decoded synchronously by the created source.
fit:ImageFitImageFit.containScaling and cropping policy within the widget’s allotted cell area.
glyph:ImageGlyphImageGlyph.halfBlockSymbol palette for the glyph-art fallback. ImageGlyph.halfBlock is the conservative default; ImageGlyph.quarterBlock roughly doubles horizontal resolution at the cost of more font-glyph reliance. Ignored when the surface renders inline pixels (SurfaceCapabilities.images reports placements) — that path is already pixel-perfect and needs no palette.
backgroundColor:Color?—For the glyph-art fallback, semitransparent pixels (0 < α < 255) are alpha-composited against this color when non-null: out = α · src + (1−α) · bg. Fully-transparent pixels are also flattened to backgroundColor. True-pixel placements retain the source alpha. More
semanticLabel:String?—Describes the image for screen readers, agents, tests, and inspectors. More

Shorthand for Image(source: ImageSource.decoded(decoded)) — pass an already-decoded package:image Image (e.g. from an HTTP fetch, generated programmatically, or transformed).

ParameterTypeDefaultDescription
decodedimg.ImagerequiredAlready-decoded pixels to render directly.
fit:ImageFitImageFit.containScaling and cropping policy within the widget’s allotted cell area.
glyph:ImageGlyphImageGlyph.halfBlockSymbol palette for the glyph-art fallback. ImageGlyph.halfBlock is the conservative default; ImageGlyph.quarterBlock roughly doubles horizontal resolution at the cost of more font-glyph reliance. Ignored when the surface renders inline pixels (SurfaceCapabilities.images reports placements) — that path is already pixel-perfect and needs no palette.
backgroundColor:Color?—For the glyph-art fallback, semitransparent pixels (0 < α < 255) are alpha-composited against this color when non-null: out = α · src + (1−α) · bg. Fully-transparent pixels are also flattened to backgroundColor. True-pixel placements retain the source alpha. More
semanticLabel:String?—Describes the image for screen readers, agents, tests, and inspectors. More

Image is defined in packages/fleury/lib/src/catalog/image.dart.

Category: Text & content · All widgets