FluentBadge class
A Fluent 2 badge: a small, non-interactive status or count marker.
FluentBadge(
color: FluentBadgeColor.danger,
appearance: FluentBadgeAppearance.tint,
icon: const Icon(FluentIcons.alert_20_filled),
child: const Text('9'),
)
Both icon and child are optional; with neither, the badge is a bare dot sized to its own height.
It is a marker, not a control: there is no onPressed, no focus ring, and
no hover, pressed or disabled treatment, because Fluent ships no such
tokens for Badge. Wrap it in your own gesture surface if a badge has to be
tappable, so the affordance is visible in the call site rather than hidden
in here.
Customisation follows the same three rungs as FluentButton. style is
merged last and wins; FluentBadgeTheme restyles a subtree; and
resolveFluentBadgeState, resolveFluentBadgeStyle and buildFluentBadge
are public so any one of them can be replaced without forking this widget.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- FluentBadge
Constructors
- FluentBadge({Key? key, Widget? child, Widget? icon, FluentBadgeColor color = FluentBadgeColor.brand, FluentBadgeSize size = FluentBadgeSize.medium, FluentBadgeAppearance appearance = FluentBadgeAppearance.filled, FluentBadgeIconPosition iconPosition = FluentBadgeIconPosition.before, FluentBadgeStyle? style, String? semanticLabel})
-
Creates a badge with an optional
iconandchildlabel.const
Properties
- appearance → FluentBadgeAppearance
-
Fill and outline treatment.
final
- child → Widget?
-
The label. Null for an icon-only or empty badge.
final
- color → FluentBadgeColor
-
Semantic colour family.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- icon → Widget?
-
Optional leading or trailing icon.
final
- iconPosition → FluentBadgeIconPosition
-
Which side of the label the icon sits on.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- semanticLabel → String?
-
Announced by assistive technology.
final
- size → FluentBadgeSize
-
Height and type ramp.
final
- style → FluentBadgeStyle?
-
Overrides layered over the theme defaults. Merged last, so it wins.
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