getDynamicValue function
get Dynamic Value from obj and convert it to specific type
Implementation
dynamic getDynamicValue(DartObject obj, String name) {
// print('getDynamicValue name:$name, obj: ${obj.toString()}');
if (!ifExist(obj, name)) {
return null;
}
final String type = obj
.getField(name)
.toString()
.substring(0, obj.getField(name).toString().indexOf(' '))
.toLowerCase();
switch (type) {
case 'string':
return getStringValue(obj, name);
case 'int':
return getIntValue(obj, name);
case 'bool':
return getBoolValue(obj, name);
default:
return null;
}
}