toggleBit method
Sets the n
th bit if v
is true
, otherwise clears.
If v
is not provided defaults to the opposit of the current value.
Returns the new value.
Implementation
@nonVirtual
// ignore: avoid_positional_boolean_parameters
T toggleBit(int n, [bool? v]) {
v ??= !isSet(n);
return v ? setBit(n) : clearBit(n);
}