updateAndGet method
T
updateAndGet(
- T updater(
- T current
Applies the updater function to the current value, sets the result,
and returns the new value.
final newValue = counter.updateAndGet((current) => current * 2);
print(newValue); // 10
Implementation
T updateAndGet(T Function(T current) updater) {
final newValue = updater(value);
value = newValue;
return newValue;
}