HelpPeerColorOption.deserialize constructor

HelpPeerColorOption.deserialize(
  1. BinaryReader reader
)

Deserialize.

Implementation

factory HelpPeerColorOption.deserialize(BinaryReader reader) {
  // Read [HelpPeerColorOption] fields.
  final flags = reader.readInt32();
  final hidden = (flags & 1) != 0;
  final colorId = reader.readInt32();
  final hasColorsField = (flags & 2) != 0;
  final colors =
      hasColorsField ? reader.readObject() as HelpPeerColorSetBase : null;
  final hasDarkColorsField = (flags & 4) != 0;
  final darkColors =
      hasDarkColorsField ? reader.readObject() as HelpPeerColorSetBase : null;
  final hasChannelMinLevelField = (flags & 8) != 0;
  final channelMinLevel = hasChannelMinLevelField ? reader.readInt32() : null;

  // Construct [HelpPeerColorOption] object.
  final returnValue = HelpPeerColorOption(
    hidden: hidden,
    colorId: colorId,
    colors: colors,
    darkColors: darkColors,
    channelMinLevel: channelMinLevel,
  );

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