setProperty method

void setProperty(
  1. dynamic prop,
  2. dynamic val
)

update a property. If this is a HasController (i.e. Widget), notify it of changes

Implementation

void setProperty(dynamic prop, dynamic val) {
  Function? func = setters()[prop];
  if (func == null && this is HasController) {
    func = (this as HasController).controller.getBaseSetters()[prop];
  }

  if (func != null) {
    func(val);

    // ask our controller to notify its listeners of changes
    if (this is HasController) {
      (this as HasController)
          .controller
          .dispatchChanges(KeyValue(prop.toString(), val));
    } else if (this is EnsembleController) {
      (this as EnsembleController).notifyListeners();
    }
  } else {
    throw InvalidPropertyException(
        'Object with id:${id ?? ''} does not have a settable property named $prop');
  }
}