writeMap<K, V> method
Encodes a map with length prefix
Format: u32 length + (key, value) pairs
Example:
final map = {'a': 1, 'b': 2};
encoder.writeMap(
map,
(key) => encoder.writeString(key),
(value) => encoder.writeU32(value),
);
Implementation
void writeMap<K, V>(
Map<K, V> map,
void Function(K) writeKey,
void Function(V) writeValue,
) {
writeU32(map.length);
for (final entry in map.entries) {
writeKey(entry.key);
writeValue(entry.value);
}
}