encode static method
Implementation
static List<int> encode({
required List<Object?> protoValues,
required ProtoMessageConfig config,
}) {
final bufferFields = config.fields;
if (bufferFields.length != protoValues.length) {
throw ProtoException(
"The values and field IDs must have the same length.",
details: {
"fieldIds": bufferFields.length.toString(),
"variables": protoValues.length.toString(),
},
);
}
return protoValues.indexed
.map((e) {
final value = e.$2;
if (value == null) return null;
final encode = _encodeField(
value: value,
config: config.fields.elementAt(e.$1),
syntax: config.syntax,
);
return encode;
})
.expand((e) => e ?? <int>[])
.toList();
}