toMap method

Map<DfBaseField, dynamic> toMap()

Implementation

Map<DfBaseField, dynamic> toMap() {
  Map<String,dynamic> json = toJson();
  if (json != null) {
    for (DfBaseField field in fields()) {
      String fieldName = field.name;
      if (field is DfDbField) {
        fieldName = field.getSelectQueryAlias();
      }

      if (field.fieldType.isDateTime) {
        if (json[fieldName] != null && json[fieldName] is String && json[fieldName].length > 0)
          field.value = DfConverter.stringToDate(json[fieldName]);
      }
      else {
        field.value = json[fieldName];
      }
    }
  }

  Map<DfBaseField,dynamic> result = Map<DfBaseField,dynamic>();
  fields().where((field) => field.displayOnly == null || !field.displayOnly).forEach((field) => result[field] = field.value);
  return result;
}