DoubleExtension extension

Extension utilities for nullable double values.

Includes helpers for rounding, safe math operations, formatting numbers, converting to currency, percentage formatting, and range checks.

on

Properties

abs double

Available on double?, provided by the DoubleExtension extension

Returns the absolute value.
no setter
isNegative bool

Available on double?, provided by the DoubleExtension extension

Returns true if the value is less than zero.
no setter
isPositive bool

Available on double?, provided by the DoubleExtension extension

Returns true if the value is greater than zero.
no setter

Methods

ceilTo({required int fractionDigits}) double

Available on double?, provided by the DoubleExtension extension

Ceils the number to fractionDigits decimal places.
clamp({required double min, required double max}) double

Available on double?, provided by the DoubleExtension extension

Clamps the number between min and max.
floorTo({required int fractionDigits}) double

Available on double?, provided by the DoubleExtension extension

Floors the number to fractionDigits decimal places.
formatNumber({String locale = 'en_US', int decimalDigits = 0}) String

Available on double?, provided by the DoubleExtension extension

Formats number with commas based on locale.
isBetween({required double min, required double max}) bool

Available on double?, provided by the DoubleExtension extension

Checks if the number is between min and max.
roundTo({required int fractionDigits}) double

Available on double?, provided by the DoubleExtension extension

Rounds the number to fractionDigits decimal places.
safe() double

Available on double?, provided by the DoubleExtension extension

Returns the value or 0.0 if null.
safeDivide({num? other}) double

Available on double?, provided by the DoubleExtension extension

Safely divides this number by other, returning 0 if either is null or if dividing by zero.
safeMultiply({num? other}) double

Available on double?, provided by the DoubleExtension extension

Returns this number multiplied safely by other.
toCurrency({CurrencyCountry country = CurrencyCountry.ID, bool usingSymbol = true, int decimalDigits = 0}) String

Available on double?, provided by the DoubleExtension extension

Converts the number into a currency format using CurrencyCountry.
toPercentage({int decimalDigits = 0}) String

Available on double?, provided by the DoubleExtension extension

Converts the number to a percentage string.
toPercentageWithSpace({int decimalDigits = 0}) String

Available on double?, provided by the DoubleExtension extension

Converts the number into a formatted percentage with a space.
toRupiah({bool usingSymbol = true}) String

Available on double?, provided by the DoubleExtension extension

Converts a number to Indonesian Rupiah format.
toShortFormat() String

Available on double?, provided by the DoubleExtension extension

Converts large numbers into short notation: