set method
Implementation
void set(String? fieldName, Object? value,
{int? field_table_id, Type? targetType}) {
if (fieldName == null) throw ArgumentError("fieldName must not be null");
int? tid = field_table_id ?? table_id;
if (tid == null) throw ArgumentError("There must be a table_id.");
if (targetType == int) {
// Values which are supposed to be ints but are empty strings should be null
if (value.runtimeType == String) {
String v = value as String;
if (v.length == 0) value = null;
}
}
FieldStruct fs = FieldStruct(tid, fieldName, value);
int index = _fieldStructList.length;
String uniqueKey = DataTools.convertUniqueKey(tid, fieldName);
if (_fieldDataMap.containsKey(uniqueKey)) {
_fieldStructList[_fieldDataMap[uniqueKey]!] = fs;
} else {
_fieldStructList.add(fs);
_fieldDataMap[uniqueKey] = index;
}
}