Poll.deserialize constructor

Poll.deserialize(
  1. BinaryReader reader
)

Deserialize.

Implementation

factory Poll.deserialize(BinaryReader reader) {
  // Read [Poll] fields.
  final id = reader.readInt64();
  final flags = reader.readInt32();
  final closed = (flags & 1) != 0;
  final publicVoters = (flags & 2) != 0;
  final multipleChoice = (flags & 4) != 0;
  final quiz = (flags & 8) != 0;
  final question = reader.readString();
  final answers = reader.readVectorObject<PollAnswerBase>();
  final hasClosePeriodField = (flags & 16) != 0;
  final closePeriod = hasClosePeriodField ? reader.readInt32() : null;
  final hasCloseDateField = (flags & 32) != 0;
  final closeDate = hasCloseDateField ? reader.readDateTime() : null;

  // Construct [Poll] object.
  final returnValue = Poll(
    id: id,
    closed: closed,
    publicVoters: publicVoters,
    multipleChoice: multipleChoice,
    quiz: quiz,
    question: question,
    answers: answers,
    closePeriod: closePeriod,
    closeDate: closeDate,
  );

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