toMap method
Convert the model instance to a map.
Implementation
Map<String, dynamic> toMap() {
final map = <String, dynamic>{};
// Add attributes
for (final key in _attributes.keys) {
if (!_isHidden(key)) {
map[key] = getAttribute(key);
}
}
// Add appends
final allAppendKeys = {...appends.keys, ..._runtimeAppends};
for (final key in allAppendKeys) {
map[key] = getAttribute(key);
}
// Add relations (if loaded)
if (this is HasRelations) {
final relations = (this as HasRelations).relations;
for (final key in relations.keys) {
if ((this as HasRelations).relationLoaded(key) && !_isHidden(key)) {
map[key] = (this as HasRelations).getRelation(key);
}
}
}
return map;
}