setProperty static method
Sets value of object property specified by its name.
If the property does not exist or introspection fails this method doesn't do anything and doesn't any throw errors.
obj
an object to write property to.name
a name of the property to set.value
a new value for the property to set.
Implementation
static void setProperty(obj, String name, value) {
if (obj == null) throw Exception('Object cannot be null');
// if (name == null) throw Exception('Property name cannot be null');
var foundName = _findWriteField(obj, name);
if (foundName != null) {
try {
var im = reflect(obj);
// Fix name for setters which have '=' at the end
foundName = Symbol(_extractName(foundName));
im.setField(foundName, value);
} catch (ex) {
// Ignore exceptions...
}
}
}