PollResults.deserialize constructor

PollResults.deserialize(
  1. BinaryReader reader
)

Deserialize.

Implementation

factory PollResults.deserialize(BinaryReader reader) {
  // Read [PollResults] fields.
  final flags = reader.readInt32();
  final min = (flags & 1) != 0;
  final hasResultsField = (flags & 2) != 0;
  final results = hasResultsField
      ? reader.readVectorObject<PollAnswerVotersBase>()
      : null;
  final hasTotalVotersField = (flags & 4) != 0;
  final totalVoters = hasTotalVotersField ? reader.readInt32() : null;
  final hasRecentVotersField = (flags & 8) != 0;
  final recentVoters =
      hasRecentVotersField ? reader.readVectorObject<PeerBase>() : null;
  final hasSolutionField = (flags & 16) != 0;
  final solution = hasSolutionField ? reader.readString() : null;
  final hasSolutionEntitiesField = (flags & 16) != 0;
  final solutionEntities = hasSolutionEntitiesField
      ? reader.readVectorObject<MessageEntityBase>()
      : null;

  // Construct [PollResults] object.
  final returnValue = PollResults(
    min: min,
    results: results,
    totalVoters: totalVoters,
    recentVoters: recentVoters,
    solution: solution,
    solutionEntities: solutionEntities,
  );

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