SubZeroBadge class

A versatile badge component following the SubZero 2.0 Design System.

Supports two variants:

  • Dot: A simple indicator without count
  • Count: Displays a numeric value with overflow handling (99+)

Can be used standalone or attached to a child widget (e.g., Avatar, Icon).

Example usage:

// Standalone count badge
SubZeroBadge(
  variant: SubZeroBadgeVariant.count,
  count: 5,
)

// Badge attached to an icon
SubZeroBadge(
  variant: SubZeroBadgeVariant.dot,
  child: Icon(Icons.notifications),
)

// Count badge with custom style
SubZeroBadge(
  variant: SubZeroBadgeVariant.count,
  count: 150,
  maxCount: 99,
  style: SubZeroBadgeStyle.outlined,
  child: SubZeroAvatar(name: 'John'),
)
Inheritance
Available extensions

Constructors

SubZeroBadge({Key? key, SubZeroBadgeVariant variant = SubZeroBadgeVariant.dot, int count = 0, int maxCount = 99, SubZeroBadgeStyle style = SubZeroBadgeStyle.filled, SubZeroBadgeSize size = SubZeroBadgeSize.medium, Widget? child, SubZeroBadgeAlignment alignment = const SubZeroBadgeAlignment(), bool showBadge = true, Color? backgroundColor, Color? foregroundColor, String? semanticLabel})
const
SubZeroBadge.count({Key? key, required int count, int maxCount = 99, SubZeroBadgeStyle style = SubZeroBadgeStyle.filled, SubZeroBadgeSize size = SubZeroBadgeSize.medium, Widget? child, SubZeroBadgeAlignment alignment = const SubZeroBadgeAlignment(), bool showBadge = true, Color? backgroundColor, Color? foregroundColor, String? semanticLabel})
Factory constructor for a count badge
factory
SubZeroBadge.dot({Key? key, SubZeroBadgeStyle style = SubZeroBadgeStyle.filled, SubZeroBadgeSize size = SubZeroBadgeSize.medium, Widget? child, SubZeroBadgeAlignment alignment = const SubZeroBadgeAlignment(), bool showBadge = true, Color? backgroundColor, String? semanticLabel})
Factory constructor for a dot badge
factory

Properties

alignment → SubZeroBadgeAlignment
Badge alignment configuration when attached to a child
final
backgroundColor → Color?
Custom background color (overrides style)
final
child → Widget?
The widget to attach the badge to (optional)
final
count → int
The count to display (only used when variant is SubZeroBadgeVariant.count)
final
foregroundColor → Color?
Custom text/border color (overrides style)
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxCount → int
Maximum count before showing overflow (e.g., 99+)
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
semanticLabel → String?
Semantic label for accessibility
final
showBadge → bool
Whether to show the badge (useful for conditionally hiding)
final
size → SubZeroBadgeSize
The size preset for the badge
final
style → SubZeroBadgeStyle
The visual style of the badge
final
variant → SubZeroBadgeVariant
The badge variant (dot or count)
final

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
withCountBadge({required int count, int maxCount = 99, SubZeroBadgeStyle style = SubZeroBadgeStyle.filled, SubZeroBadgeSize size = SubZeroBadgeSize.medium, SubZeroBadgeAlignment alignment = const SubZeroBadgeAlignment(), bool show = true}) → Widget

Available on Widget, provided by the SubZeroBadgeExtension extension

Wrap this widget with a count badge
withDotBadge({SubZeroBadgeStyle style = SubZeroBadgeStyle.filled, SubZeroBadgeSize size = SubZeroBadgeSize.medium, SubZeroBadgeAlignment alignment = const SubZeroBadgeAlignment(), bool show = true}) → Widget

Available on Widget, provided by the SubZeroBadgeExtension extension

Wrap this widget with a dot badge

Operators

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