PollAnswerVoters.deserialize constructor

PollAnswerVoters.deserialize(
  1. BinaryReader reader
)

Deserialize.

Implementation

factory PollAnswerVoters.deserialize(BinaryReader reader) {
  // Read [PollAnswerVoters] fields.
  final flags = reader.readInt32();
  final chosen = (flags & 1) != 0;
  final correct = (flags & 2) != 0;
  final option = reader.readBytes();
  final hasVotersField = (flags & 4) != 0;
  final voters = hasVotersField ? reader.readInt32() : null;
  final hasRecentVotersField = (flags & 4) != 0;
  final recentVoters =
      hasRecentVotersField ? reader.readVectorObject<PeerBase>() : null;

  // Construct [PollAnswerVoters] object.
  final returnValue = PollAnswerVoters(
    chosen: chosen,
    correct: correct,
    option: option,
    voters: voters,
    recentVoters: recentVoters?.items,
  );

  // Now return the deserialized [PollAnswerVoters].
  return returnValue;
}