decodeTyped<T> function
Implementation
T decodeTyped<T>(dynamic raw, {TransferCodec<T>? codec}) {
if (raw is T) {
return raw;
}
if (raw == null) {
throw CodecException.typeMismatch(T, raw.runtimeType);
}
codec ??= TransferCodec.find<T>();
if (codec != null) {
return (codec as dynamic).decode(raw) as T;
}
throw ApiError.invalidType(T);
}