readList<T> method

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

Reads a List of values of type T from field in obj.

Implementation

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