Badge
Displays a small label or tag for status indicators, counts, or categorization.
Installation
Usage
Properties
| Property | Type | Description |
|---|---|---|
| text | String | The text to display in the badge. |
| variant | BadgeVariant | The variant of the badge (primary, secondary, destructive, outline, custom). |
| icon | IconData | An optional leading icon for the badge. |
| child | Widget | A custom child widget to replace the default content. |
| backgroundColor | Color | The background color of the badge. |
| foregroundColor | Color | The text and icon color of the badge. |
| borderColor | Color | The border color (used with outline and custom variants). |
| borderWidth | double | The border width (used with outline and custom variants). |
| borderRadius | double | The border radius of the badge. Defaults to pill shape. |
| padding | EdgeInsetsGeometry | The padding inside the badge. |
| fontSize | double | The font size of the badge text. |
| fontWeight | FontWeight | The font weight of the badge text. |
| iconSize | double | The size of the leading icon. |
| gap | double | The gap between the icon and text. |
Variants
FlutBadge provides several variants, each with its own appearance. You can choose the variant that best suits your needs.
Primary
The primary variant is the default. It uses the primary color scheme for background and text.
Secondary
The secondary variant uses the secondary color scheme. Ideal for less prominent labels.
Destructive
The destructive variant uses the error color scheme. Use for warnings or error states.
Outline
The outline variant has a transparent background with a border. Useful for subtle labeling.
Custom
The custom variant lets you fully control the badge appearance with custom colors, borders, and border radius.
With Icons
You can add a leading icon to any badge variant.
Helper Class
Use the Badge helper class for quick access to common variants.