BotAppSettings.deserialize constructor

BotAppSettings.deserialize(
  1. BinaryReader reader
)

Deserialize.

Implementation

factory BotAppSettings.deserialize(BinaryReader reader) {
  // Read [BotAppSettings] fields.
  final flags = reader.readInt32();
  final hasPlaceholderPathField = (flags & 1) != 0;
  final placeholderPath = hasPlaceholderPathField ? reader.readBytes() : null;
  final hasBackgroundColorField = (flags & 2) != 0;
  final backgroundColor = hasBackgroundColorField ? reader.readInt32() : null;
  final hasBackgroundDarkColorField = (flags & 4) != 0;
  final backgroundDarkColor =
      hasBackgroundDarkColorField ? reader.readInt32() : null;
  final hasHeaderColorField = (flags & 8) != 0;
  final headerColor = hasHeaderColorField ? reader.readInt32() : null;
  final hasHeaderDarkColorField = (flags & 16) != 0;
  final headerDarkColor = hasHeaderDarkColorField ? reader.readInt32() : null;

  // Construct [BotAppSettings] object.
  final returnValue = BotAppSettings(
    placeholderPath: placeholderPath,
    backgroundColor: backgroundColor,
    backgroundDarkColor: backgroundDarkColor,
    headerColor: headerColor,
    headerDarkColor: headerDarkColor,
  );

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