listFrom static method
Implementation
static IValue listFrom(List list) {
if (list is List<bool>) {
return IValue._(typeCode: typeCodeBoolList, data: list);
} else if (list is List<int>) {
return IValue._(typeCode: typeCodeLongList, data: list);
} else if (list is List<double>) {
return IValue._(typeCode: typeCodeDoubleList, data: list);
} else if (list is List<Tensor>) {
return IValue._(typeCode: typeCodeTensorList, data: list);
} else if (list is List<IValue>) {
final size = list.length;
if (size > 0) {
final typeCode0 = list.first._typeCode;
for (var i = 1; i < size; i++) {
if (list[i]._typeCode != typeCode0) {
throw ArgumentError("List must contain items of the same type");
}
}
}
return IValue._(typeCode: typeCodeList, data: list);
}
throw ArgumentError("Unsupported type ${list.runtimeType}");
}