compactMap<K, V> static method
Implementation
static CustomLayout compactMap<K, V>(Layout keyLayout, Layout valueLayout,
{String? property}) {
final layout = struct([
seq(
MapEntryLayout(
keyLayout: keyLayout, valueLayout: valueLayout, property: ""),
compactOffset(),
property: 'values')
]);
return CustomLayout<Map<String, dynamic>, Map<K, V>>(
layout: layout,
decoder: (data) {
final List<MapEntry<K, V>> values = (data['values'] as List).cast();
return Map.fromEntries(values);
},
encoder: (values) => {'values': values.entries.toList()},
property: property,
);
}