jsonMapToMap static method
Implementation
static Map<String, Object?> jsonMapToMap(
Type originType, Map<String, Object?> jsonMap) {
var typeMap = <TypeCheck, Object? Function(dynamic value)>{
const TypeCheck<DateTime>(): (value) => toDateTime(value)
};
const reflector = Reflector();
ClassMirror mirror = reflector.reflectType(originType) as ClassMirror;
mirror.declarations.forEach((key, value) {
if (value is VariableMirror) {
var unserializer = typeMap.entries
.firstWhereOrNull(
(type) => type.key.matchesType(value.reflectedType))
?.value;
if (unserializer != null) {
jsonMap[key] = unserializer(jsonMap[key]);
}
}
});
return jsonMap;
}