readMap<K, V> method
Decodes a map with length prefix
Format: u32 length + (key, value) pairs
Example:
final map = decoder.readMap<String, int>(
() => decoder.readString(),
() => decoder.readU32(),
);
Implementation
Map<K, V> readMap<K, V>(K Function() readKey, V Function() readValue) {
final length = readU32();
final map = <K, V>{};
for (int i = 0; i < length; i++) {
final key = readKey();
final value = readValue();
map[key] = value;
}
return map;
}