pretty_num 0.0.3
pretty_num: ^0.0.3 copied to clipboard
A lightweight Dart library to format ugly numbers into clean, readable strings like 1.5M, 1,234,567, or 2.4 MB.
example/pretty_num_example.dart
import 'package:pretty_num/pretty_num.dart';
void main() {
// 1. Компактные числа
print(1500.toCompact()); // Выведет: 1.5K
print(2500000.toCompact()); // Выведет: 2.5M
// 2. Читаемые числа с разделителями
print(123456789.toReadable()); // Выведет: 123 456 789
// 3. Конвертация байтов
print(1048576.toBytes()); // Выведет: 1.0 MB
// 4. Форматирование валют
print(1500.toCurrency(symbol: '₽')); // Выведет: 1 500 ₽
// 5. Римские цифры
print(2026.toRoman()); // Выведет: MMXXVI
// 6. Проценты
print(0.154.toPercent()); // Выведет: 15.4%
// 7. Склонение слов (русский язык)
print(1.plural('товар', 'товара', 'товаров')); // Выведет: 1 товар
print(3.plural('товар', 'товара', 'товаров')); // Выведет: 3 товара
print(5.plural('товар', 'товара', 'товаров')); // Выведет: 5 товаров
}