toDatabaseMap method
Prepare the model for database insertion/update.
Serializes each attribute to its DB-storable form:
- AttributeCaster:
get()to normalise the Dart type, thenset()for DB. - Type-based casts (
bool,DateTime,List,Map): converted inline.
Implementation
Map<String, dynamic> toDatabaseMap() {
final map = <String, dynamic>{};
for (final key in _attributes.keys) {
map[key] = _serializeForDatabase(key, _attributes[key]);
}
return map;
}