Skip to main content

animated_count 0.1.2 copy "animated_count: ^0.1.2" to clipboard
animated_count: ^0.1.2 copied to clipboard

A tiny Flutter widget that counts an integer up or down to its new value. One plain Text, so font scaling, wrapping and screen readers just work.

example/lib/main.dart

import 'package:animated_count/animated_count.dart';
import 'package:flutter/material.dart';

void main() => runApp(const ExampleApp());

/// Shows an [AnimatedCount] that counts to a new number on every tap.
class ExampleApp extends StatelessWidget {
  /// Creates the example app.
  const ExampleApp({super.key});

  @override
  Widget build(BuildContext context) => MaterialApp(
    theme: ThemeData(colorSchemeSeed: Colors.teal),
    home: const _Home(),
  );
}

class _Home extends StatefulWidget {
  const _Home();

  @override
  State<_Home> createState() => _HomeState();
}

class _HomeState extends State<_Home> {
  int _posters = 12;

  @override
  Widget build(BuildContext context) => Scaffold(
    appBar: AppBar(title: const Text('animated_count')),
    body: Center(
      child: AnimatedCount(
        value: _posters,
        suffix: _posters == 1 ? ' poster' : ' posters',
        countFromZero: true,
        style: Theme.of(context).textTheme.displaySmall,
      ),
    ),
    floatingActionButton: Row(
      mainAxisSize: MainAxisSize.min,
      spacing: 12,
      children: [
        FloatingActionButton(
          onPressed: () => setState(() => _posters = _posters > 0 ? _posters - 7 : 0),
          child: const Icon(Icons.remove),
        ),
        FloatingActionButton(
          onPressed: () => setState(() => _posters += 130),
          child: const Icon(Icons.add),
        ),
      ],
    ),
  );
}
0
likes
0
points
42
downloads

Publisher

verified publisherdev.plakat-kompass.de

Weekly Downloads

A tiny Flutter widget that counts an integer up or down to its new value. One plain Text, so font scaling, wrapping and screen readers just work.

Repository (GitHub)
View/report issues

Topics

#animation #counter #text #widget

License

unknown (license)

Dependencies

flutter

More

Packages that depend on animated_count