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 embedsDetails
Section titled “Details”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.
Constructors
Section titled “Constructors”Image()
Section titled “Image()”| Parameter | Type | Default | Description |
|---|---|---|---|
source: | ImageSource | required | Pixel source decoded when the widget is mounted or replaced. |
fit: | ImageFit | ImageFit.contain | Scaling and cropping policy within the widget’s allotted cell area. |
glyph: | ImageGlyph | ImageGlyph.halfBlock | Symbol 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. ProvidebackgroundColor(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.
Image.file()
Section titled “Image.file()”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.
| Parameter | Type | Default | Description |
|---|---|---|---|
path | String | required | File path read by the synchronously decoded, shared file cache. |
fit: | ImageFit | ImageFit.contain | Scaling and cropping policy within the widget’s allotted cell area. |
glyph: | ImageGlyph | ImageGlyph.halfBlock | Symbol 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.bytes()
Section titled “Image.bytes()”Shorthand for Image(source: ImageSource.bytes(bytes)).
| Parameter | Type | Default | Description |
|---|---|---|---|
bytes | Uint8List | required | Encoded image bytes decoded synchronously by the created source. |
fit: | ImageFit | ImageFit.contain | Scaling and cropping policy within the widget’s allotted cell area. |
glyph: | ImageGlyph | ImageGlyph.halfBlock | Symbol 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.decoded()
Section titled “Image.decoded()”Shorthand for Image(source: ImageSource.decoded(decoded)) —
pass an already-decoded package:image Image (e.g. from an HTTP
fetch, generated programmatically, or transformed).
| Parameter | Type | Default | Description |
|---|---|---|---|
decoded | img.Image | required | Already-decoded pixels to render directly. |
fit: | ImageFit | ImageFit.contain | Scaling and cropping policy within the widget’s allotted cell area. |
glyph: | ImageGlyph | ImageGlyph.halfBlock | Symbol 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 |
Source
Section titled “Source”Image is defined in packages/fleury/lib/src/catalog/image.dart.
Category: Text & content · All widgets