decode method Null safety

XdrPreconditionsV2 decode(
  1. XdrDataInputStream stream
)

Implementation

static XdrPreconditionsV2 decode(XdrDataInputStream stream) {
  XdrTimeBounds? tb;
  XdrLedgerBounds? lb;
  XdrUint64? sqN;

  int timeBoundsPresent = stream.readInt();
  if (timeBoundsPresent != 0) {
    tb = XdrTimeBounds.decode(stream);
  }

  int ledgerBoundsPresent = stream.readInt();
  if (ledgerBoundsPresent != 0) {
    lb = XdrLedgerBounds.decode(stream);
  }

  int sequenceNumberPresent = stream.readInt();
  if (sequenceNumberPresent != 0) {
    sqN = XdrUint64.decode(stream);
  }

  XdrUint64 minSA = XdrUint64.decode(stream);
  XdrUint32 minSLG = XdrUint32.decode(stream);

  int signersSize = stream.readInt();
  List<XdrSignerKey> keys = List<XdrSignerKey>.empty(growable: true);
  for (int i = 0; i < signersSize; i++) {
    keys.add(XdrSignerKey.decode(stream));
  }

  XdrPreconditionsV2 decoded = XdrPreconditionsV2(minSA, minSLG, keys);

  if (tb != null) {
    decoded.timeBounds = tb;
  }
  if (lb != null) {
    decoded.ledgerBounds = lb;
  }
  if (sqN != null) {
    decoded.sequenceNumber = sqN;
  }
  return decoded;
}