encode static method

List<int> encode(
  1. int fieldNumber,
  2. dynamic value
)

Encode a protobuf field with the given fieldNumber and value.

Implementation

static List<int> encode(int fieldNumber, dynamic value) {
  if (value is BigInt) {
    return _encodeBigInt(fieldNumber, value);
  } else if (value is int) {
    return _encodeInt(fieldNumber, value);
  } else if (value is TronEnumerate) {
    return _encodeInt(fieldNumber, value.value);
  } else if (value is TronAddress) {
    return _encodeBytes(fieldNumber, value.toBytes());
  } else if (value is List<int>) {
    return _encodeBytes(fieldNumber, value);
  } else if (value is String) {
    return _encodeBytes(fieldNumber, StringUtils.encode(value));
  } else if (value is TronProtocolBufferImpl) {
    return _encodeBytes(fieldNumber, value.toBuffer());
  } else if (value is List) {
    return _encodeList(fieldNumber, value);
  } else if (value is bool) {
    return _encodeBool(fieldNumber, value);
  } else if (value is Map) {
    return _encodeMap(fieldNumber, value);
  }
  throw MessageException("unsupported type",
      details: {"runtime": value.runtimeType, "value": value});
}