FHUIntValueNotifierExtension extension
IntValueNotifierExtension
Extension on ValueNotifier<int>
for direct manipulation of integer values.
This extension augments the ValueNotifier with methods tailored for integer operations.
It allows for straightforward arithmetic operations and transformations on the int value,
such as incrementing, decrementing, or toggling between values, without explicitly
accessing the .value
property.
This extension is particularly useful in reactive programming contexts where integer values are frequently modified and need to be handled in a clean, concise manner.
Example:
final intValueNotifier = 10.notifier;
intValueNotifier.increment(); // Directly increments the value (now 11)
intValueNotifier.toggleBetween(11, 5); // Toggles the value to 5 as current is 11
// These operations directly modify the int value within the ValueNotifier without accessing `.value`
- on
Properties
Methods
-
abs(
) → int - Returns the absolute value of this integer.
-
ceilToDouble(
) → double -
Returns
this.toDouble()
. -
floorToDouble(
) → double -
Returns
this.toDouble()
. -
gcd(
int other) → int -
Returns the greatest common divisor of this integer and
other
. -
modInverse(
int modulus) → int -
Returns the modular multiplicative inverse of this integer
modulo
modulus
. -
modPow(
int exponent, int modulus) → int -
Returns this integer to the power of
exponent
modulomodulus
. -
roundToDouble(
) → double -
Returns
this.toDouble()
. -
toRadixString(
int radix) → String -
Converts this to a string representation in the given
radix
. -
toSigned(
int width) → int -
Returns the least significant
width
bits of this integer, extending the highest retained bit to the sign. This is the same as truncating the value to fit inwidth
bits using an signed 2-s complement representation. The returned value has the same bit value in all positions higher thanwidth
. -
toUnsigned(
int width) → int -
Returns the least significant
width
bits of this integer as a non-negative number (i.e. unsigned representation). The returned value has zeros in all bit positions higher thanwidth
. -
truncateToDouble(
) → double -
Returns
this.toDouble()
.
Operators
-
operator &(
int other) → int - Bit-wise and operator.
-
operator <<(
int shiftAmount) → int -
Shift the bits of this integer to the left by
shiftAmount
. -
operator >>(
int shiftAmount) → int -
Shift the bits of this integer to the right by
shiftAmount
. -
operator >>>(
int shiftAmount) → int -
Bitwise unsigned right shift by
shiftAmount
bits. -
operator ^(
int other) → int - Bit-wise exclusive-or operator.
-
operator unary-(
) → int - Return the negative value of this integer.
-
operator |(
int other) → int - Bit-wise or operator.
-
operator ~(
) → int - The bit-wise negate operator.