NumExt extension

on

Properties

isInteger → bool

Available on num?, provided by the NumExt extension

Returns true if the validated number has no fractional part.
no setter
isNegative → bool

Available on num?, provided by the NumExt extension

Returns true if the validated number is less than 0.
no setter
isPositive → bool

Available on num?, provided by the NumExt extension

Returns true if the validated number is greater than 0.
no setter
isZero → bool

Available on num?, provided by the NumExt extension

Returns true if the validated number is equal to 0.
no setter

Methods

abs() → num

Available on num?, provided by the NumExt extension

Returns the absolute value of the validated number.
clamp(num lowerLimit, num upperLimit) → num

Available on num?, provided by the NumExt extension

Clamps the validated number to be within the range lowerLimit, upperLimit.
isBetween(num min, num max, {bool inclusive = true}) → bool

Available on num?, provided by the NumExt extension

Checks if the validated number falls within a specified range [min, max]. By default, the check is inclusive. Set inclusive to false for an exclusive check.
percentageOf(num total) → double

Available on num?, provided by the NumExt extension

Calculates what percentage the validated number is of a given total. Returns 0.0 if total is 0 or null.
roundToPrecision(int precision) → double

Available on num?, provided by the NumExt extension

Rounds the validated number to a specified number of decimal precision. For example, (10.12345).roundToPrecision(2) will return 10.12
toCurrencyAmount() → String

Available on num?, provided by the NumExt extension

Returns price with currency
toDoubleDigits(int fractionDigits) → String

Available on num?, provided by the NumExt extension

Formats the validated number to a string with a fixed number of fractionDigits. Returns "0.00" (or based on fractionDigits) if the number is null.
validate({num value = 0}) → num

Available on num?, provided by the NumExt extension

Validate given double is not null and returns given value if null.