count_number 0.3.71+1 copy "count_number: ^0.3.71+1" to clipboard
count_number: ^0.3.71+1 copied to clipboard

Animates the counting process of a value based on a spring simulation. Starts an internal periodic timer that checks the state of the simulation.

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.

Features #

  • 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';

Usage #

Initialize a CountNumber object:

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

  @override
  void initState() {
    _countNumber = CountNumber(
      endValue: 50,
      onUpdate: (value) => setState(() => _number = value as int),
    );
    super.initState();
  }

  @override
  void dispose() {
    _countNumber.stop();
    super.dispose();
  }
}

Run the start() method:

 @override
  Widget build(BuildContext context) {
    _countNumber.start();

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Expanded(
        child: Center(
            child: Text(
            _number.toString(),
            style: Theme.of(context).textTheme.headline1,
          ),
        )
      ),
    );
  }
2
likes
150
pub points
31%
popularity

Publisher

verified publishermichm.de

Animates the counting process of a value based on a spring simulation. Starts an internal periodic timer that checks the state of the simulation.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on count_number