handleValue method
helper function convert raw field to class field cautions: currently not checking subsubType, since assuming map shouldn't have {xx: DOC|USER}
Implementation
FutureOr<dynamic> handleValue(Entry entry,dynamic data)async{
if(data==null)return data;
if(entry.type==EntryType.date){
return DateTime.fromMillisecondsSinceEpoch(data);
}else if(entry.type==EntryType.doc){
return await getData_raw(entry.path!,data);
}else if(entry.type==EntryType.user){
return await getData_raw(consts.userClassDoc,data);
} else if(entry.type==EntryType.list){
if(entry.subType==EntryType.date){
return data.map((e) => DateTime.fromMillisecondsSinceEpoch(e)).toList();
}else if(entry.subType==EntryType.doc){
return await Future.wait(data.map<Future<Map<String,dynamic>?>>((e) => getData_raw(entry.path!,e)));
}else if(entry.subType==EntryType.user){
return await Future.wait(data.map<Future<Map<String,dynamic>?>>((e) => getData_raw(consts.userClassDoc,e)));
}
}else if(entry.type==EntryType.map){
data=Map.fromEntries(data.entries.map((e) => MapEntry(
entry.subType==EntryType.date?DateTime.fromMillisecondsSinceEpoch(e.key):e.key,
entry.subsubType==EntryType.date?DateTime.fromMillisecondsSinceEpoch(e.value):e.value)));
if(entry.subType==EntryType.doc){
return _convertMapKey(data,entry.path!);
}else if(entry.subType==EntryType.user){
return _convertMapKey(data,consts.userClassDoc);
}
}
else {
return data;
}
}