getProperties static method
Get values of all properties in specified object and returns them as a map.
The object can be a user defined object, map or array. Returned properties correspondently are object properties, map key-pairs or array elements with their indexes.
obj
an object to get properties from. Returns a map, containing the names of the object's properties and their values.
Implementation
static Map<String, dynamic> getProperties(obj) {
var map = <String, dynamic>{};
if (obj is IValueWrapper) obj = obj.innerValue();
if (obj == null) {
// Do nothing
} else if (obj is Map) {
for (var key in obj.keys) {
map[key.toString()] = obj[key];
}
} else if (obj is List) {
for (var index = 0; index < obj.length; index++) {
map[index.toString()] = obj[index];
}
} else {
map = PropertyReflector.getProperties(obj);
}
return map;
}