addListener method

  1. @override
void addListener(
  1. void callback(
    1. T value
    )
)
override

Adds a listener/callback that will be called when the property value changes

Implementation

@override
void addListener(void Function(T value) callback) {
  if (listeners.contains(callback)) {
    return;
  }
  if (listeners.isEmpty) {
    // Since we don't clean the changed flag for properties that don't have
    // listeners, we clean it the first time we add a listener to it
    clearChanges();
    rootViewModelInstance.addCallback(this);
  }
  listeners.add(callback);
}