Avatar
An image element with a fallback for representing the user.
Loading preview...
Installation
Usage
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| imageUrl | String? | null | URL of the image to display. |
| fallbackText | String? | null | Text used for the fallback — only the first letter is shown (uppercased). |
| size | AvatarSize | md | Size preset. |
| customSize | double? | null | Exact size in logical pixels when size is AvatarSize.custom. |
| backgroundColor | Color? | primary | Background color shown behind the fallback letter. |
| textColor | Color? | onPrimary | Color of the fallback letter. |
| textStyle | TextStyle? | — | Full text style override for the fallback letter. |
| borderRadius | BorderRadius? | circular(8) | Border radius used when shape is BoxShape.rectangle. |
| shape | BoxShape | circle | Shape of the avatar (BoxShape.circle or BoxShape.rectangle). |
| child | Widget? | null | Custom child widget. Overrides imageUrl and fallback. |
| borderWidth | double | 0 | Width of the border stroke. |
| borderColor | Color | transparent | Color of the border. |
Sizes
Sm
24×24 pixels. For tight layouts like list items or inline mentions.
Md
32×32 pixels. The default size.
Lg
40×40 pixels. For comment threads, user cards, and chat UIs.
Xl
48×48 pixels. For profile headers and prominent user displays.
Custom
Specify an exact size with Avatar.custom().
Shapes
Circle (default)
Rounded Rectangle
Fallback
When imageUrl is null or not provided, the avatar displays the first letter of fallbackText (uppercased) over a colored background.
With Border
Add a decorative border using borderWidth and borderColor.
Helper Class
The Avatar helper class provides named constructors for each size.