set method

void set(
  1. T update(
    1. T previous
    )
)

Functional update: applies update to the current value, then value=. Prefer this in async handlers to avoid read-modify-write races.

Implementation

void set(T Function(T previous) update) => value = update(_value);