update method

void update(
  1. WidgetState state,
  2. bool add
)

Adds state to value if add is true, and removes it otherwise, and notifies listeners if value has changed.

Implementation

void update(WidgetState state, bool add) {
  final bool valueChanged = add ? value.add(state) : value.remove(state);
  if (valueChanged) {
    notifyListeners();
  }
}