NumExt extension
- on
-
- num?
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 - 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 rangelowerLimit, 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. Setinclusiveto 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 giventotal. Returns 0.0 iftotalis 0 or null. -
roundToPrecision(
int precision) → double -
Available on num?, provided by the NumExt extension
Rounds the validated number to a specified number of decimalprecision. For example, (10.12345).roundToPrecision(2) will return 10.12 -
toCurrencyAmount(
) → String - 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 offractionDigits. Returns "0.00" (or based onfractionDigits) if the number is null. -
validate(
{num value = 0}) → num - Validate given double is not null and returns given value if null.