setValue method

  1. @override
void setValue(
  1. T value, {
  2. bool notify = true,
  3. bool forceNotify = false,
})
override

Robust value setter. notify when set is called when value is different. Disable notify to prevent propagation of this value change. This can be handy when we change value multiple times during one function call and we want to notify just last change. Enable forceNotify to notify listeners even if value is not changed.

Implementation

@override
void setValue(T value, {bool notify = true, bool forceNotify = false}) {
  if (_value == value) {
    if (forceNotify) {
      this.notify();
    }

    return;
  }

  _value = value;

  if (notify || forceNotify) {
    this.notify();
  }
}