toBytes method
Implementation
@override
List<int> toBytes() {
// Create a KafkaBytesBuilder with the request header.
var builder =
KafkaBytesBuilder.withRequestHeader(apiKey, apiVersion, correlationId);
// Ensure topicNames is a Set.
Set<String> topicNameSet =
topicNames is Set<String> ? topicNames! : <String>{};
// Add the topic names to the builder.
builder.addArray(topicNameSet, KafkaType.string);
// Take the bytes from the builder.
var body = builder.takeBytes();
// Add the body to the builder.
builder.addBytes(body);
// Return the bytes from the builder.
return builder.takeBytes();
}