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 openAnswers = (flags & 64) != 0;
  final revotingDisabled = (flags & 128) != 0;
  final shuffleAnswers = (flags & 256) != 0;
  final hideResultsUntilClose = (flags & 512) != 0;
  final creator = (flags & 1024) != 0;
  final subscribersOnly = (flags & 2048) != 0;
  final question = reader.readObject() as TextWithEntitiesBase;
  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;
  final hasCountriesIso2Field = (flags & 4096) != 0;
  final countriesIso2 =
      hasCountriesIso2Field ? reader.readVectorString() : null;
  final hash = reader.readInt64();

  // Construct [Poll] object.
  final returnValue = Poll(
    id: id,
    closed: closed,
    publicVoters: publicVoters,
    multipleChoice: multipleChoice,
    quiz: quiz,
    openAnswers: openAnswers,
    revotingDisabled: revotingDisabled,
    shuffleAnswers: shuffleAnswers,
    hideResultsUntilClose: hideResultsUntilClose,
    creator: creator,
    subscribersOnly: subscribersOnly,
    question: question,
    answers: answers.items,
    closePeriod: closePeriod,
    closeDate: closeDate,
    countriesIso2: countriesIso2?.items,
    hash: hash,
  );

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