NumExtension extension

Helpers on every number: durations, file sizes, percentages, Persian words. 5.seconds, 1536.toBKMG()

on

Properties

days → Duration

Available on num, provided by the NumExtension extension

This many days. 7.days
no setter
hours → Duration

Available on num, provided by the NumExtension extension

This many hours. 2.hours
no setter
minutes → Duration

Available on num, provided by the NumExtension extension

This many minutes. 5.minutes
no setter
ms → Duration

Available on num, provided by the NumExtension extension

This many milliseconds. 300.ms
no setter
seconds → Duration

Available on num, provided by the NumExtension extension

This many seconds. 2.seconds, 1.5.seconds
no setter
withCommas → String

Available on num, provided by the NumExtension extension

Groups the whole part with commas, decimals untouched. 1234567.8 → "1,234,567.8"
no setter

Methods

between(num low, num high) → bool

Available on num, provided by the NumExtension extension

True when between low and high (both included). age.between(18, 60)
percentOf(num total) → double

Available on num, provided by the NumExtension extension

What percent this is of total. 25.percentOf(200) → 12.5
toBKMG() → String

Available on num, provided by the NumExtension extension

Bytes → readable size. 1536 → "1.5 KB"
toPercent({int digits = 0, bool fromFraction = true}) → String

Available on num, provided by the NumExtension extension

As a percent label; digits decimals; set fromFraction false when it is already 0-100. 0.256.toPercent() → "26%"
toPersianWords() → String

Available on num, provided by the NumExtension extension

Number in Persian words. 1250.toPersianWords() → "یک هزار و دویست و پنجاه"