PubSubMessage constructor

PubSubMessage({
  1. required String topic,
  2. required String content,
  3. required String sender,
  4. Uint8List? data,
})

Creates a PubSub message.

content is the lossy UTF-8 view of the payload; data carries the raw wire bytes. When data is omitted it defaults to the UTF-8 encoding of content — supply both when the payload is not valid UTF-8 so binary payloads survive intact.

Implementation

PubSubMessage({
  required this.topic,
  required this.content,
  required this.sender,
  Uint8List? data,
}) : data = data ?? Uint8List.fromList(utf8.encode(content));