toMapQuery method

Map<String, dynamic> toMapQuery({
  1. Map<NUIEntType, EntCustomerMapper>? customMapper,
})

Implementation

Map<String, dynamic> toMapQuery({Map<NUIEntType, EntCustomerMapper>? customMapper}){
  final fieldMap = _fieldMap();
  final json = toMap();
  for(String key in json.keys){
    final val = json[key];
    if(val is NUIEnt){
      json[key] = jsonEncode(val);
    }
    if(val is Map){
      json[key] = jsonEncode(val);
    }
    if(val is List<NUIEnt>){
      json[key] = jsonEncode(val);
    }
    if(val is List){
      json[key] = jsonEncode(val);
    }
    if(val is DateTime){
      final field = fieldMap[key];
      if(field?.additionalFormat != null){
        json[key] = dateToString(val, format: field!.additionalFormat);
      }
      else {
        json[key] = dateToString(val);
      }
    }

    if(customMapper != null){
      final field = fieldMap[key];
      final mapper = customMapper[field!.type];
      if(mapper != null){
        json[key] = mapper(json[key]);
      }
    }
  }
  return json;
}