decodeDartObject static method
dynamic
decodeDartObject(
- DartObject? dartObject
Implementation
static dynamic decodeDartObject(DartObject? dartObject) {
if (dartObject == null || dartObject.type == null) {
return null;
}
if (dartObject.type?.toString() == 'String') {
return dartObject.toStringValue();
} else if (dartObject.type!.toString() == 'int') {
return dartObject.toIntValue();
} else if (dartObject.type!.toString() == 'double') {
return dartObject.toDoubleValue();
} else if (dartObject.type!.toString() == 'bool') {
return dartObject.toBoolValue();
} else if (dartObject.type!.toString().startsWith('List')) {
final List<dynamic> list = [];
for (final DartObject item in dartObject.toListValue() ?? []) {
list.add(decodeDartObject(item));
}
return list;
} else if (dartObject.type!.toString().startsWith('Map')) {
final Map<String, dynamic> map = {};
for (final key in dartObject.toMapValue()!.keys.toList()) {
if (key?.type.toString() == 'FieldValidator') {
final str = key!.getField('_name').toString().split("'")[1];
map['$str'] = decodeDartObject(dartObject.toMapValue()?[key]);
//// print('Field Validator Map Value: ${map['$str'].toString()} keys: ${map['$str'].keys.toString()}');
} else {
map[key?.toStringValue() ?? ' '] = decodeDartObject(dartObject.toMapValue()?[key]);
}
}
return map;
} else {
return null;
}
}