fromMapByMap method

RecordList fromMapByMap(
  1. Map? map
)

Copies the value of the specified Map to this RecordList.

Implementation

RecordList fromMapByMap(Map<dynamic?, dynamic?>? map){
  if(map == null){
    return this;
  }
  if(schema.hasPrimary && schema.primaryFields.length == 1){
    map.forEach(
      (key, value){
        Record rec = createRecord();
        schema.fields.forEach(
          (field){
            if(field.isPrimary){
              rec.setByName(field.name, key);
            }else{
              if(value is Map){
                if(field.isRecord){
                  rec.setByName(field.name, _dataSet == null || field.schema == null ? null : _dataSet!.createNestedRecord(field.schema!).fromMap(value as Map<String, Object?>?));
                }else{
                  rec.fromMap(value as Map<String, Object?>?);
                }
              }else if(value is List && field.isRecordList){
                rec.setByName(field.name, _dataSet == null || field.schema == null ? null : _dataSet!.createNestedRecordList(field.schema!).fromMap(value));
              }else{
                rec.setByName(field.name, value);
              }
            }
          }
        );
        add(rec);
      }
    );
  }else{
    return this;
  }
  return this;
}