mx_formatter 1.0.0
mx_formatter: ^1.0.0 copied to clipboard
A Dart package for formatting quantities, percentages, and monetary values. Removes trailing zeros and adds thousand separators with ease.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.0.0 - 2025-01-01 #
Added #
NumMXFormatterExtension— extension onnumthat adds.moneyFormat(),.qtyFormat()and.percentFormat()directly to everyintanddoublevalue, enabling a concise fluent call-site syntax:102321121.moneyFormat()→"102 321 121"10.12123123.qtyFormat()→"10.12"10.0.percentFormat()→"10%"
Added #
QuantityFormatter.format()— formats adoublevalue by rounding to a maximum number of decimal places and removing trailing zeros.10.12123123→"10.12"10.0→"10"
QuantityFormatter.formatPercent()— same asformat()with a%suffix.10.12123123→"10.12%"10.0→"10%"
MoneyFormatter.format()— formats adoubleas a monetary amount using space as the thousand separator and trimming trailing decimal zeros.102321121→"102 321 121"10321121.21→"10 321 121.21"
- Configurable
maxDecimalPlaces,thousandSeparator, anddecimalSeparatorparameters on all formatters. - Full null-safe, pure-Dart implementation — supports Android, iOS, Linux, macOS, Web, and Windows without any additional dependencies.