Badge class

Reusable Badge component for the Alter Design System.

Figma Specifications (Node 124:4003):

  • Variants: 18 color variants (gray, white, red, orange, yellow, green, teal, indigo, purple, pink, amber, lime, emerald, cyan, sky, brand, slate, zinc)
  • Typography: Body/caption (Geist 12px, Regular 400, line-height 16px)
  • Padding: 6px vertical, 8px horizontal
  • Border Radius: 12px
  • Gap: 4px
  • Content container: row with 0px vertical, 2px horizontal padding, 2px gap
  • Left & Right Icons: 16x16px
  • Action Button: 16x16px container with 6px border radius, containing 12x12px clear icon
Inheritance

Constructors

Badge({Key? key, String label = 'Label', BadgeColor color = BadgeColor.gray, bool hasLeftIcon = false, IconData? leftIcon, bool hasRightIcon = false, IconData? rightIcon, bool hasAction = false, IconData? actionIcon, VoidCallback? onActionTap})
Creates a Badge instance.
const

Properties

actionIcon → IconData?
Custom icon data for the action button (defaults to clear/close).
final
color → BadgeColor
The color swatch variant applied to background, text, and border.
final
hasAction → bool
Whether the trailing action button should be rendered.
final
hashCode → int
The hash code for this object.
no setterinherited
hasLeftIcon → bool
Whether the leading left icon should be rendered.
final
hasRightIcon → bool
Whether the trailing right icon should be rendered.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label → String
Text string displayed inside the badge.
final
leftIcon → IconData?
The icon data for the leading icon.
final
onActionTap → VoidCallback?
Callback executed when the trailing action button is pressed.
final
rightIcon → IconData?
The icon data for the trailing icon.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(BuildContext context) → Widget
Describes the part of the user interface represented by this widget.
override
createElement() → StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

version → const String
Component version for reference. v1.1.0: Removed body tap interaction and isInteractive property; Badge now exclusively uses hasAction and onActionTap for action button interactions. v1.0.2: Decoupled main badge onTap from action button onActionTap with independent hit regions. v1.0.1: Fixed hasAction, hasLeftIcon, and hasRightIcon to strictly respect their boolean visibility flags. v1.0.0: Initial release matching Figma Node 124:4003.