encode method
Encode encodes the given message.
Encode may expect a specific type of message, and will error if this type is not given.
Implementation
@override
Uint8List encode(Object message) {
  if (message is! GeneratedMessage) {
    throw _invalidTypeError;
  }
  return Utf8Encoder().convert(
    jsonEncode(
      message.toProto3Json(
        typeRegistry: typeRegistry,
      ),
    ),
  );
}