update method

T update(
  1. T updater(
    1. T value
    )
)

Replaces the value by calculating a new value from the current value.

This is useful for immutable list/map updates:

answers.update((items) => [...items, newAnswer]);

Implementation

T update(T Function(T value) updater) {
  final next = updater(_value);
  set(next);
  return next;
}