number_formatter 0.0.2 number_formatter: ^0.0.2 copied to clipboard
A Flutter package to format numbers with K, M, B suffixes example 1000 = 1k, 3600 = 3.6k 100,000 = 100k.
import 'package:flutter/material.dart';
import 'package:number_formatter/number_formatter.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Number Formatter Example'),
),
body: Center(
child: NumberDisplay(),
),
),
);
}
}
class NumberDisplay extends StatelessWidget {
@override
Widget build(BuildContext context) {
int number1 = 1000;
int number2 = 1200;
int number3 = 2500000;
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('Formatted number1: ${formatNumber(number1)}'),
Text('Formatted number2: ${formatNumber(number2)}'),
Text('Formatted number3: ${formatNumber(number3)}'),
],
);
}
}