FHUDoubleValueNotifierExtension extension
DoubleValueNotifierExtension
Extension on ValueNotifier<double>
to enable direct manipulation of double values.
This extension provides convenient methods for handling double precision floating-point
numbers within a ValueNotifier. It simplifies arithmetic and other operations on double
values, such as rounding, scaling, or clamping, without the need to explicitly access the
.value
property.
Ideal for scenarios where reactive double values need to be manipulated frequently and with precision, this extension ensures more readable and concise code.
Example:
final doubleValueNotifier = 10.5.notifier;
doubleValueNotifier.increment(2.5); // Directly adds 2.5 to the value (now 13.0)
doubleValueNotifier.round(); // Directly rounds the value (now 13.0)
// These operations modify the double value within the ValueNotifier without accessing `.value`
Methods
-
abs(
) → double - The absolute value of this number.
-
ceil(
) → int - Returns the least integer that is not smaller than this number.
-
ceilToDouble(
) → double -
Returns the least integer double value no smaller than
this
. -
floor(
) → int - Returns the greatest integer no greater than this number.
-
floorToDouble(
) → double -
Returns the greatest integer double value no greater than
this
. -
remainder(
num other) → double -
The remainder of the truncating division of
this
byother
. -
round(
) → int - Returns the integer closest to this number.
-
roundToDouble(
) → double -
Returns the integer double value closest to
this
. -
truncate(
) → int - Returns the integer obtained by discarding any fractional part of this number.
-
truncateToDouble(
) → double -
Returns the integer double value obtained by discarding any fractional
digits from
this
.
Operators
-
operator %(
num other) → double -
Euclidean modulo of this number by
other
. -
operator *(
num other) → double -
Multiplies this number by
other
. -
operator +(
num other) → double -
Adds
other
to this number. -
operator -(
num other) → double -
Subtracts
other
from this number. -
operator /(
num other) → double -
Divides this number by
other
. -
operator unary-(
) → double - The negation of this value.
-
operator ~/(
num other) → int - Truncating division operator.