AnimatedCounter class

Animated rolling-digit counter backed by CustomPainter.

Every animation frame updates the persistent CounterPainter in-place and calls markNeedsPaint() — zero widget builds during animation. Static decorations (prefix, suffix, signs) are rendered in a lightweight Row that rebuilds only once per value change.

For custom per-digit widgets or transition builders use AnimatedCounterBuilder.

Inheritance

Constructors

AnimatedCounter({Key? key, AnimatedCounterStyle? style, num? value, AnimatedCounterController? controller, Duration duration = const Duration(milliseconds: 300), Duration negativeSignDuration = const Duration(milliseconds: 150), Curve curve = Curves.linear, TextStyle? textStyle, String? prefix, String? infix, String? suffix, int fractionDigits = 0, int wholeDigits = 1, bool hideLeadingZeroes = true, double numberAlignment = 0.0, String? thousandSeparator, List<int> groupingPattern = const [3], String decimalSeparator = '.', TextStyle? separatorStyle, MainAxisAlignment mainAxisAlignment = MainAxisAlignment.center, CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center, EdgeInsets padding = EdgeInsets.zero, bool useTabularFigures = true, TextStyle? prefixStyle, TextStyle? infixStyle, TextStyle? suffixStyle, TextOverflow? prefixOverflow, TextOverflow? infixOverflow, TextOverflow? suffixOverflow, bool showPositiveSign = false, Duration? positiveSignDuration, String? semanticsLabel, VoidCallback? onAnimationEnd, VoidCallback? onAnimationStart, AxisDirection flipDirection = AxisDirection.up, num? minValue, num? maxValue, Color? increasingColor, Color? decreasingColor, Duration colorFadeDuration = const Duration(milliseconds: 800), Widget? prefixWidget, Widget? infixWidget, Widget? suffixWidget, Widget? thousandSeparatorWidget, Widget? decimalSeparatorWidget, Widget? negativeSignWidget, Widget? positiveSignWidget, Duration? staggerDelay, StaggerDirection staggerDirection = StaggerDirection.rightToLeft, bool compactNotation = false, bool triggerHaptics = false, int? compactFractionDigits, num initialValue = 0, NumeralSystem numeralSystem = NumeralSystem.latin, String numeralMapper(int digit)?, CounterTransition transition = CounterTransition.slide, Duration? reverseDuration, Curve? reverseCurve, Duration? startDelay, double speedMultiplier = 1.0, Map<num, String>? compactAbbreviations, VoidCallback? onPause, VoidCallback? onResume, VoidCallback? onReset, VoidCallback? onRepeat, VoidCallback? onReverse, bool repaintBoundary = true, double autoEaseThreshold = 100000, Curve? curveForDigit(int digitIndex)?, Color? colorResolver(num value)?, double interpolation(double from, double to, double t)?, double bounceOvershoot = 0.0, double bounceElasticity = 4.0, bool fast = false, CounterPainterBuilder? painterBuilder})
const

Properties

autoEaseThreshold double
finalinherited
bounceElasticity double
finalinherited
bounceOvershoot double
finalinherited
colorFadeDuration Duration
no setterinherited
colorResolver Color? Function(num value)?
finalinherited
compactAbbreviations Map<num, String>?
finalinherited
compactFractionDigits int?
finalinherited
compactNotation bool
finalinherited
controller AnimatedCounterController?
finalinherited
crossAxisAlignment CrossAxisAlignment
no setterinherited
curve Curve
finalinherited
curveForDigit Curve? Function(int digitIndex)?
finalinherited
decimalSeparator String
finalinherited
decimalSeparatorWidget Widget?
finalinherited
decoration Decoration?
Container decoration drawn around the whole counter (style-only).
no setterinherited
decreasingColor Color?
no setterinherited
duration Duration
finalinherited
fast bool
Fast mode: every digit column does a SINGLE step from its old digit to its new digit (one slot of movement), regardless of numeric distance — e.g. 1000 → 9999 slides each column once (1→9, 0→9, …) instead of the full cascading odometer roll. Applies to every transition.
finalinherited
flipDirection AxisDirection
finalinherited
fractionDigits int
finalinherited
groupingPattern List<int>
finalinherited
hashCode int
The hash code for this object.
no setterinherited
hideLeadingZeroes bool
finalinherited
increasingColor Color?
no setterinherited
infix String?
finalinherited
infixOverflow TextOverflow?
finalinherited
infixStyle TextStyle?
no setterinherited
infixWidget Widget?
finalinherited
initialValue num
finalinherited
interpolation double Function(double from, double to, double t)?
finalinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
mainAxisAlignment MainAxisAlignment
no setterinherited
maxValue num?
finalinherited
minValue num?
finalinherited
negativeSignDuration Duration
finalinherited
negativeSignWidget Widget?
finalinherited
numberAlignment double
Horizontal alignment of visible digits within the stable full-width slot. -1.0 = left, 0.0 = center (default), 1.0 = right.
no setterinherited
numeralMapper String Function(int digit)?
finalinherited
numeralSystem NumeralSystem
finalinherited
onAnimationEnd VoidCallback?
finalinherited
onAnimationStart VoidCallback?
finalinherited
onPause VoidCallback?
finalinherited
onRepeat VoidCallback?
finalinherited
onReset VoidCallback?
finalinherited
onResume VoidCallback?
finalinherited
onReverse VoidCallback?
finalinherited
padding EdgeInsets
no setterinherited
painterBuilder CounterPainterBuilder?
Optional factory for a custom CounterPainter subclass.
final
positiveSignDuration Duration?
finalinherited
positiveSignWidget Widget?
finalinherited
prefix String?
finalinherited
prefixOverflow TextOverflow?
finalinherited
prefixStyle TextStyle?
no setterinherited
prefixWidget Widget?
finalinherited
repaintBoundary bool
finalinherited
reverseCurve Curve?
finalinherited
reverseDuration Duration?
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
semanticsLabel String?
finalinherited
separatorStyle TextStyle?
no setterinherited
showPositiveSign bool
finalinherited
speedMultiplier double
finalinherited
staggerDelay Duration?
finalinherited
staggerDirection StaggerDirection
finalinherited
startDelay Duration?
finalinherited
style AnimatedCounterStyle?
Aggregate visual style. Overrides the deprecated loose visual params field-by-field (see the resolving getters below).
finalinherited
suffix String?
finalinherited
suffixOverflow TextOverflow?
finalinherited
suffixStyle TextStyle?
no setterinherited
suffixWidget Widget?
finalinherited
textStyle TextStyle?
no setterinherited
thousandSeparator String?
finalinherited
thousandSeparatorWidget Widget?
finalinherited
transition CounterTransition
finalinherited
triggerHaptics bool
finalinherited
useTabularFigures bool
no setterinherited
value num?
finalinherited
wholeDigits int
finalinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<AnimatedCounter>
Creates the mutable state for this widget at a given location in the tree.
override
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