tuple static method
Implementation
static BcsType<List, List> tuple(
List<BcsType> types,
[BcsTypeOptions<List, List>? options]
) {
return BcsType<List, List>(
name: '(${types.map((t) => t.name).join(', ')})',
serializedSize: (values, {BcsWriterOptions? options}) {
int total = 0;
for (int i = 0; i < types.length; i++) {
final size = types[i].serializedSize(values[i]);
if (size == null) {
return null;
}
total += size;
}
return total;
},
read: (reader) {
final result = [];
for (final type in types) {
result.add(type.read(reader));
}
return result;
},
write: (value, writer) {
for (int i = 0; i < types.length; i++) {
types[i].write(value[i], writer);
}
},
validate: (value) {
options?.validate?.call(value);
if (value.length != types.length) {
throw ArgumentError('Expected List of length ${types.length}, found ${value.length}');
}
},
);
}