NullableDoubleX extension
Extension on double? to add utility methods.
This extension provides two methods:
orZero: a getter that returns the double if it's not null, otherwise it returns zero.or: a method that returns the double if it's not null, otherwise it returns a default value.
Example usage:
double? nullableDouble = null;
print(nullableDouble.orZero); // Outputs: 0.0
print(nullableDouble.or(defaultValue: 5.5)); // Outputs: 5.5
nullableDouble = 10.5;
print(nullableDouble.orZero); // Outputs: 10.5
print(nullableDouble.or(defaultValue: 5.5)); // Outputs: 10.5
- on
Properties
- orZero → double
-
Available on double?, provided by the NullableDoubleX extension
Returns the double if it's not null, otherwise it returns zero.no setter
Methods
-
isNegativeValue(
) → bool -
Available on double?, provided by the NullableDoubleX extension
Checks if the double is negative. -
isPositive(
) → bool -
Available on double?, provided by the NullableDoubleX extension
Checks if the double is positive. -
or(
{double defaultValue = 0}) → double -
Available on double?, provided by the NullableDoubleX extension
Returns the double if it's not null, otherwise it returns a default value.