update method

void update(
  1. dynamic updateFunction(
    1. T value
    )
)

Updates the state with a new value using the provided update function. Maintains immutability by creating a new instance of the value.

Implementation

void update(Function(T value) updateFunction) {
  final newValue = _value;
  updateFunction(newValue);
  _value = newValue;
  _listener?.call();
}