KeyboardButtonStyle.deserialize constructor

KeyboardButtonStyle.deserialize(
  1. BinaryReader reader
)

Deserialize.

Implementation

factory KeyboardButtonStyle.deserialize(BinaryReader reader) {
  // Read [KeyboardButtonStyle] fields.
  final flags = reader.readInt32();
  final bgPrimary = (flags & 1) != 0;
  final bgDanger = (flags & 2) != 0;
  final bgSuccess = (flags & 4) != 0;
  final hasIconField = (flags & 8) != 0;
  final icon = hasIconField ? reader.readInt64() : null;

  // Construct [KeyboardButtonStyle] object.
  final returnValue = KeyboardButtonStyle(
    bgPrimary: bgPrimary,
    bgDanger: bgDanger,
    bgSuccess: bgSuccess,
    icon: icon,
  );

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