read method

  1. @override
DOOMessage read(
  1. BinaryReader reader
)
override

Is called when a value has to be decoded.

Implementation

@override
DOOMessage read(BinaryReader reader) {
  final numOfFields = reader.readByte();
  final fields = <int, dynamic>{
    for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
  };
  return DOOMessage(
    id: fields[0] as int,
    content: fields[1] as String?,
    messageType: fields[2] as int?,
    contentType: fields[3] as String?,
    contentAttributes: fields[4] as dynamic,
    createdAt: fields[5] as String,
    conversationId: fields[6] as int?,
    attachments: (fields[7] as List?)?.cast<dynamic>(),
    sender: fields[8] as DOOEventMessageUser?,
  );
}