vector<T, Input> static method
BcsType<List<T> , dynamic>
vector<T, Input>(
- BcsType<
T, Input> type, [ - BcsTypeOptions<
List< ? optionsT> , Iterable<Input> >
Implementation
static BcsType<List<T>, dynamic> vector<T, Input>(
BcsType<T, Input> type,
[BcsTypeOptions<List<T>, Iterable<Input>>? options]
) {
return BcsType<List<T>, dynamic>(
name: 'vector<${type.name}>',
read: (reader) {
final length = reader.readULEB();
final result = <T>[];
for (int i = 0; i < length; i++) {
result.add(type.read(reader));
}
return result;
},
write: (value, writer) {
writer.writeULEB(value.length);
for (final item in value) {
type.write(item, writer);
}
},
validate: (value) {
options?.validate?.call(value);
},
);
}