addClasses method

FutureOr<Map<String, dynamic>?> addClasses(
  1. DocumentSnapshot<Map<String, dynamic>> doc, {
  2. Idex? index,
})

Implementation

FutureOr<Map<String,dynamic>?> addClasses(DocumentSnapshot<Map<String,dynamic>> doc,{Idex? index})async{
  if(!doc.exists)return null;
  final r = doc.data()!..[consts.dataIdKey]=doc.id;
  final entries=index?.entries;
  if(entries==null)return r;

  final futures=<Future>[];
  r.forEach((k, v) {
    if(entries.containsKey(k)) {
      futures.add(Future(()=>handleValue(entries[k]!, doc[k])).then((v) => r[k]=v));
    }
  });
  await Future.wait(futures);
  r[consts.dataClassIdKey]=index!.id;
  r[consts.dataClassNameKey]=index.name;
  return r;
}