Badge.count constructor
Convenience constructor for creating a badge with a numeric label based on count.
Initializes label with a Text widget that shows:
- the
countvalue if it is less than or equal tomaxCount, - otherwise, shows '
maxCount+'.
For example, if count is 1000 and maxCount is 99, the label will display '99+'.
Implementation
Badge.count({
super.key,
this.backgroundColor,
this.textColor,
this.smallSize,
this.largeSize,
this.textStyle,
this.padding,
this.alignment,
this.offset,
required int count,
int maxCount = 999,
this.isLabelVisible = true,
this.child,
}) : assert(count >= 0, 'count must be non-negative'),
assert(maxCount > 0, 'maxCount must be positive'),
label = Text(count > maxCount ? '$maxCount+' : '$count');