decodeMap<K, V> method
Decodes the data for the given key or id as a map of key-value pairs.
Optionally takes Decodables to decode the keys and values of the map.
Implementation
@override
Map<K, V> decodeMap<K, V>(String key, {int? id, Decodable<K>? keyUsing, Decodable<V>? valueUsing}) {
try {
return _decodeMap(_value[key] as Map, keyUsing, valueUsing);
} on TypeError {
throw CodableException.wrap(
CodableException.unexpectedType(
expected: 'Map<$K, $V>', actual: '${_value[key].runtimeType}', data: _value[key]),
method: 'decode',
hint: '["$key"]',
);
} catch (e, st) {
Error.throwWithStackTrace(CodableException.wrap(e, method: 'decode', hint: '["$key"]'), st);
}
}