read<T> method

T read<T>(
  1. Map<String, Object?> obj,
  2. String field
)

Reads a value of type T from field in obj.

Implementation

T read<T>(
  Map<String, Object?> obj,
  String field,
) {
  final value = obj[field];
  if (value is! T) {
    throw DebugAdapterInvalidArgumentException(
      requestName: request,
      argumentName: field,
      expectedType: T,
      actualType: value.runtimeType,
      actualValue: value,
    );
  }
  return obj[field] as T;
}