NumberTicker constructor

const NumberTicker({
  1. Key? key,
  2. num? initialNumber,
  3. required num number,
  4. required NumberTickerFormatted? formatter,
  5. Duration? duration,
  6. Curve? curve,
  7. TextStyle? style,
})

Creates a NumberTicker with formatted text display.

This is the standard constructor that displays animated numbers as text using a formatting function. The formatter receives the current numeric value and must return a string representation for display.

Parameters:

  • initialNumber (num?, optional): Starting value for first animation.
  • number (num, required): Target value to animate to and display.
  • formatter (NumberTickerFormatted, required): Function to format numbers as strings.
  • duration (Duration?, optional): Override animation duration.
  • curve (Curve?, optional): Override animation curve.
  • style (TextStyle?, optional): Override text styling.

Example:

NumberTicker(
  initialNumber: 0,
  number: 1234.56,
  formatter: (value) => NumberFormat.currency(
    locale: 'en_US',
    symbol: '\$',
  ).format(value),
  duration: Duration(milliseconds: 750),
  style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600),
);

Implementation

const NumberTicker({
  super.key,
  this.initialNumber,
  required this.number,
  required this.formatter,
  this.duration,
  this.curve,
  this.style,
})  : builder = null,
      child = null;