update method Null safety

void update(
  1. MaterialState 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(MaterialState state, bool add) {
  final bool valueChanged = add ? value.add(state) : value.remove(state);
  if (valueChanged) {
    notifyListeners();
  }
}