cast<T2 extends ASTType<V2>, V2> method
ASTValueArray<T2, V2>
cast<
T2 extends ASTType<V2>, V2>({ - T2? componentType,
})
Implementation
ASTValueArray<T2, V2> cast<T2 extends ASTType<V2>, V2>({T2? componentType}) {
final value = this.value;
var t = componentType ?? (type as ASTTypeArray).componentType;
List<V2> v;
if (value is List<V2>) {
v = (value as List<V2>);
} else {
if (V2 == double) {
v = value.map<V2>((e) {
return e is num
? e.toDouble() as V2
: (throw ApolloVMRuntimeError(
"Can't cast `${e.runtimeType}` to `$V2`",
));
}).toList();
} else {
v = value.cast<V2>();
}
}
return ASTValueArray<T2, V2>(t as T2, v);
}