Flutter package: count_number

Animates the counting process of a value based on a spring simulation. Starts an internal periodic timer that checks the state of the simulation at each tick and calls one of the callbacks if necessary. The value can be an integer or a double.


  • Counts animated a number up or down
  • Supports integer and double values
  • Calls the callbacks only when actually necessary
  • Can be initialized as dynamic
  • Setting the property value triggers a new counting process

Getting started

Add the dependency:

flutter pub add count_number

Import the package:

import 'package:count_number/count_number.dart';


Initialize a CountNumber object:

class _HomeState extends State<Home> {
  int _number = 0;
  late CountNumber _countNumber;

  void initState() {
    _countNumber = CountNumber(
      endValue: 50,
      onUpdate: (value) => setState(() => _number = value as int),

  void dispose() {

Run the start() method:

  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      body: Expanded(
        child: Center(
            child: Text(
            style: Theme.of(context).textTheme.headline1,


Copyright 2022 Manfred Michaelis mm@michm.de