NumFormatX extension
Human-readable string formatting for num values.
These are dependency-free approximations of what intl does with full
locale support — use them for compact labels, debug output, and places
where pulling in a locale database is overkill.
- on
Methods
-
toBytes(
{int decimals = 1, bool binary = true}) → String -
Available on num, provided by the NumFormatX extension
Formats a byte count with the largest fitting unit. -
toCompact(
{int decimals = 1}) → String -
Available on num, provided by the NumFormatX extension
Abbreviates large magnitudes:1234->'1.2K',2500000->'2.5M'. -
toCurrency(
{String symbol = r'$', int decimals = 2, String separator = ',', bool suffix = false}) → String -
Available on num, provided by the NumFormatX extension
Formats this value as currency. -
toFixed(
int decimals) → String -
Available on num, provided by the NumFormatX extension
Formats with exactlydecimalsdecimal places. -
toPercentString(
{int decimals = 0}) → String -
Available on num, provided by the NumFormatX extension
Formats this fraction as a percentage, scaling by 100. -
toThousands(
{String separator = ',', int? decimals}) → String -
Available on num, provided by the NumFormatX extension
Groups the integer part into thousands. -
toTrimmed(
int decimals) → String -
Available on num, provided by the NumFormatX extension
Formats with up todecimalsdecimal places, trimming trailing zeros.