readMap<K, V> method
Reads a Map of types K
,V
from field
in obj
.
Implementation
Map<K, V> readMap<K, V>(
Map<String, Object?> obj,
String field,
) {
final value = obj[field];
if (value is! Map ||
!value.entries.every((entry) => entry.key is K && entry.value is V)) {
throw DebugAdapterInvalidArgumentException(
requestName: request,
argumentName: field,
expectedType: Map<K, V>,
actualType: value.runtimeType,
actualValue: value,
);
}
return (obj[field] as Map<Object?, Object?>).cast<K, V>();
}