TxBadge class

材料设计“徽章”。

徽章的 label 传达有关其 child 的少量信息,例如计数或状态。如果标签为 null,则这是一 个“小”徽章,显示为 smallSize 直径填充圆圈。否则,这是一个 StadiumBorder 形状的“大”徽章, 高度为 largeSize。

徽章通常用于装饰 BottomNavigationBarItem 或 NavigationRailDestination 或按钮 图标中的图标,如 TextButton.icon。徽章的默认配置旨在与默认大小(24)的 Icon 配合使用。

Inheritance

Constructors

TxBadge({Key? key, Color? backgroundColor, Color? textColor, double? smallSize, double? largeSize, TextStyle? textStyle, EdgeInsetsGeometry? padding, AlignmentGeometry? alignment, Offset? offset, Widget? label, bool isLabelVisible = true, Widget? child, ShapeBorder? shape})
创建一个徽章,将 label 堆叠在 child 之上。
const
TxBadge.count({required int count, Key? key, Color? backgroundColor, Color? textColor, double? smallSize, double? largeSize, TextStyle? textStyle, EdgeInsetsGeometry? padding, AlignmentGeometry? alignment, Offset? offset, bool isLabelVisible = true, Widget? child, ShapeBorder? shape})
方便的构造函数,用于创建带有基于 count 的 1-3 位数字标签的徽章。

Properties

alignment → AlignmentGeometry?
结合 offset 以确定 label 相对于 child 的位置。
final
backgroundColor → Color?
徽章的填充颜色。
final
child → Widget?
徽章堆叠在顶部的小组件。
final
hashCode → int
The hash code for this object.
no setterinherited
isLabelVisible → bool
如果为 false,则不包括徽章的 label。
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label → Widget?
徽章的内容,通常是包含 1 到 4 个字符的 Text 小组件。
final
largeSize → double?
如果 label 为非空,则徽章的高度。
final
offset → Offset?
结合 alignment 以确定 label 相对于 child 的位置。
final
padding → EdgeInsetsGeometry?
添加到徽章标签的填充。
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
shape → ShapeBorder?
徽章的形状
final
smallSize → double?
如果 label 为 null,则徽章的直径。
final
textColor → Color?
徽章的 label 文本的颜色。
final
textStyle → TextStyle?
锁屏提醒标签的 DefaultTextStyle。
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