toMap method

Map<String, dynamic> toMap(
  1. E entity, {
  2. MapTarget target = MapTarget.local,
})

Encodes an entity into its persisted map via each field's getter.

Every field must declare a getter:. Schema codecs are target-independent (one wire format for local and remote); target is accepted for signature parity with toDatumMap.

Implementation

Map<String, dynamic> toMap(E entity, {MapTarget target = MapTarget.local}) {
  return {
    for (final field in fields) field.name: (field as DatumFieldSpec<E, Object?>).encode(_valueOf(field, entity)),
  };
}