setProperty static method

void setProperty(
  1. dynamic obj,
  2. String? name,
  3. dynamic value
)

Recursively sets value of object and its subobjects property specified by its name.

The object can be a user defined object, map or array. The property name correspondently must be object property, map key or array index.

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 || name == null) return;

  var names = name.split('.');
  if (names.isEmpty) return;

  RecursiveObjectWriter._performSetProperty(obj, names, 0, value);
}