ModelEntity.fromMap constructor
Implementation
ModelEntity.fromMap(Map<String, dynamic> data,
{ModelInfo? model, bool check = true})
: _model = model,
id = IdUid.fromString(data['id'] as String?),
lastPropertyId = IdUid.fromString(data['lastPropertyId'] as String?),
nullSafetyEnabled = data['nullSafetyEnabled'] as bool? ?? true,
_properties = [],
_relations = [],
_backlinks = [] {
name = data['name'] as String?;
flags = data['flags'] as int? ?? 0;
ArgumentError.checkNotNull(data['properties'], "data['properties']");
for (final p in data['properties']) {
_properties.add(ModelProperty.fromMap(p as Map<String, dynamic>, this));
}
if (data['relations'] != null) {
for (final p in data['relations']) {
_relations.add(ModelRelation.fromMap(p as Map<String, dynamic>));
}
}
if (data['backlinks'] != null) {
for (final p in data['backlinks']) {
_backlinks.add(ModelBacklink.fromMap(p as Map<String, dynamic>));
}
}
if (data['constructorParams'] != null) {
constructorParams = (data['constructorParams'] as List<dynamic>)
.map((dynamic e) => e as String)
.toList(growable: false);
}
if (check) validate();
_idProperty =
properties.singleWhere((p) => (p.flags & OBXPropertyFlags.ID) != 0);
}