Image
Displays an image from a local file path. Supports PNG, JPEG, and GIF formats.
Basic Usage
Image("path/to/image.png")
Options
| Option | Type | Description | Example |
|---|---|---|---|
ImageWidth |
float32 |
Sets the display width in dp | ImageWidth(200) |
ImageHeight |
float32 |
Sets the display height in dp | ImageHeight(150) |
Fit |
ImageFit |
Sets how the image scales to fit | Fit(FitCover) |
ImageRadius |
float32 |
Sets corner radius for rounded images | ImageRadius(8) |
Image Fit Modes
| Mode | Description |
|---|---|
FitContain |
Scales to fit within bounds, preserving aspect ratio (default) |
FitCover |
Scales to cover bounds, may crop edges |
FitFill |
Stretches to fill bounds, may distort |
FitNone |
Displays at original size |
Examples
// Basic image (natural size, constrained by window)
Image("images/photo.png")
// Image with fixed width (height auto-calculated)
Image("images/photo.png", ImageWidth(200))
// Image with fixed height (width auto-calculated)
Image("images/photo.png", ImageHeight(100))
// Image with both dimensions
Image("images/photo.png", ImageWidth(200), ImageHeight(150))
// Image with FitCover (fills area, may crop)
Image("images/photo.png", ImageWidth(200), ImageHeight(100), Fit(FitCover))
// Image with FitFill (stretches to fill)
Image("images/photo.png", ImageWidth(200), ImageHeight(100), Fit(FitFill))
// Rounded image
Image("images/avatar.png", ImageWidth(100), ImageRadius(50))
// Rounded corners
Image("images/photo.png", ImageWidth(200), ImageRadius(12))
ImageFromImage
For images already loaded in memory or generated programmatically:
// Create from existing image.Image
ImageFromImage(myImage, ImageWidth(200))