Badge class
A small status/counter badge anchored to a corner of its child.
content renders inside the badge (a counter, icon, short text); with isDot it collapses to a bare dot (8px at xs to 20px at xxxl). The badge is positioned by placement and offset 25% of its size out of the corner; isInvisible hides the badge while reserving the slot. Variants map to the badge styles (solid/soft/secondary/outline), and showOutline adds a 1px background-colored ring so the badge separates from the content beneath it.
Badge(
content: const Text('3'),
color: ColorRoleToken.danger,
child: Button.secondary(onPressed: openMenu, child: const Text('Inbox')),
)
- Inheritance
Constructors
- Badge({Key? key, required Widget child, Widget? content, ColorRoleToken color = ColorRoleToken.default_, BadgeVariant? variant, PlacementToken placement = PlacementToken.topRight, SizeToken? size, bool isDot = false, bool isInvisible = false, RadiusToken? radius, bool showOutline = true})
-
Creates a badge around
child.const
Properties
- child → Widget
-
Widget the badge is anchored to.
final
- color → ColorRoleToken
-
Color role the variant paints from.
final
- content → Widget?
-
Badge content — usually a counter or short label.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDot → bool
-
Renders a bare dot instead of a labelled badge.
final
- isInvisible → bool
-
Hides the badge without removing it from the tree.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- placement → PlacementToken
-
Which corner/edge of child the badge hugs.
final
- radius → RadiusToken?
-
Optional explicit radius override. When null, ChipDefaults.radius
applies, then the per-size spec radius (sm
rounded-xl12, mdrounded-3xl24, lgrounded-2xl16).final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showOutline → bool
-
Whether a thin ring in the background color separates the badge from child.
final
- size → SizeToken?
-
Size token driving dot diameter, text scale and default radius. Defaults
to ChipDefaults.size, then SizeToken.md.
final
- variant → BadgeVariant?
-
Visual style. Defaults to BadgeVariant.solid.
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
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited