hasProperty static method

bool hasProperty(
  1. dynamic obj,
  2. String? name
)

Checks recursively if object or its subobjects has a property with specified 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.

  • obj an object to introspect.
  • name a name of the property to check. Returns true if the object has the property and false if it doesn't.

Implementation

static bool hasProperty(obj, String? name) {
  if (obj == null || name == null) return false;

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

  return RecursiveObjectReader._performHasProperty(obj, names, 0);
}