decodeListTyped<T extends List<E>?, E> function
T
decodeListTyped<
T extends List<E>?, E>( - dynamic raw, {
- String? name,
})
Implementation
T decodeListTyped<T extends List<E>?, E>(dynamic raw, {String? name}) {
if (raw is T) {
return raw;
} else if (raw is List) {
final codec = TransferCodec.find<E>();
return decodeList<T, E>(
raw, (e, n) => decodeTyped<E>(e, codec: codec, name: n),
name: name);
} else if (TypeCheck<T>().isNullable && raw == null) {
return null as T;
} else if (raw is List && raw.isEmpty) {
return <E>[] as T;
} else {
throw CodecException.typeMismatch(T, raw.runtimeType, name);
}
}