DHUNullSafeNumExtensions extension

DHUNullSafeNumExtensions

on

Properties

asBool bool

Available on num?, provided by the DHUNullSafeNumExtensions extension

Returns true if the number is greater than 0.
no setter
isNegative bool

Available on num?, provided by the DHUNullSafeNumExtensions extension

Returns true if the number is negative.
no setter
isPositive bool

Available on num?, provided by the DHUNullSafeNumExtensions extension

Returns true if the number is positive.
no setter
isZeroOrNull bool

Available on num?, provided by the DHUNullSafeNumExtensions extension

Returns true if the number is either null or zero.
no setter

Methods

percentage(num total, {bool allowDecimals = true}) num

Available on num?, provided by the DHUNullSafeNumExtensions extension

Returns the percentage of this value relative to total, optionally allowing decimals.
toDecimalString(int decimalPlaces, {bool keepTrailingZeros = false}) String

Available on num?, provided by the DHUNullSafeNumExtensions extension

Returns a string representation of the number with a given number of decimal places.
tryToDouble() double?

Available on num?, provided by the DHUNullSafeNumExtensions extension

Returns the double value of the number, or null if the number is null.
tryToInt() int?

Available on num?, provided by the DHUNullSafeNumExtensions extension

Returns the integer value of the number, or null if the number is null.