compact_number 0.0.2 copy "compact_number: ^0.0.2" to clipboard
compact_number: ^0.0.2 copied to clipboard

Convert large number to short readable format such as 10K, 5M, 10B etc.

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Compact Number'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  getCompactNumber(number) {
    final cn = CompactNumber();
    String result = cn.getValue(number);
    return result;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              "This youtube video has " + getCompactNumber(2000000) + " views.",
            ),
          ],
        ),
      ),
    );
  }
}
5
likes
140
points
30
downloads

Publisher

verified publishermddanish.dev

Weekly Downloads

Convert large number to short readable format such as 10K, 5M, 10B etc.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, intl

More

Packages that depend on compact_number