vec static method

CustomLayout vec(
  1. Layout elementLayout, {
  2. String? property,
  3. IntegerLayout? lengthSizeLayout,
})

vectors

Implementation

static CustomLayout vec(Layout elementLayout,
    {String? property, IntegerLayout? lengthSizeLayout}) {
  lengthSizeLayout ??= (lengthSizeLayout?.clone(newProperty: "length") ??
      u32(property: "length"));
  final length = padding(lengthSizeLayout, propery: "length");
  final layout = struct([
    length,
    seq(elementLayout, offset(length, -length.span), property: 'values'),
  ]);
  return CustomLayout<Map<String, dynamic>, dynamic>(
    layout: layout,
    encoder: (data) => {"values": data},
    decoder: (data) => data["values"],
    property: property,
  );
}