Skip to main content

DecodedMessage class

*[<Null safety>](https://dart.dev/null-safety)*

This represents a fully decoded message. It attempts to give uniform shape to v1 and v2 messages.

Offline Storage

Beyond ordinary offline storage concerns (secure the database, etc), here are some tips for storing and indexing messages.

The id is a good message identifier for local storage purposes. -> Tip: consider id as your primary key in the local database

But often you won't have an id, instead you'll have a conversation and want to list the messages sequentially. To support this you'll want to key by the topic and sentAt together. -> Tip: consider topic+sentAt as an index in the local database.

Storing the decoded content is difficult because it can be any type. Instead you'll want to store the encoded content because it can be reliably serialized. Later, you can decode it using Client.decodeContent. -> Tip: store the encoded content using encoded.writeToBuffer()

See the example app for a demonstration of the overall approach.

Constructors

DecodedMessage (Message_Version version, DateTime sentAt, EthereumAddress sender, EncodedContent encoded, ContentTypeId contentType, Object content, {required String id, required String topic})

Properties

content Object

This contains the content decoded by all registered codecs. e.g. for contentTypeText, the content will be a String
final

contentType ContentTypeId

This identifies the content's type.
final

encoded EncodedContent

This contains the raw encoded content.
final

hashCode int

The hash code for this object.
read-onlyinherited

id String

A unique identifier for this message. Tip: this is a good identifier for local caching purposes.
final

runtimeType Type

A representation of the runtime type of the object.
read-onlyinherited

sender EthereumAddress

Who sent the message.
final

sentAt DateTime

When the sender sent this message.
final

topic String

The topic identifier for the parent conversation.
final

version Message_Version

This identifies which type of message this contains. For the most part, you are safe to ignore this. This SDK takes pains to help you ignore the distinctions.
final

Methods

noSuchMethod(Invocation invocation) dynamic

Invoked when a non-existent method or property is accessed.
inherited

toString() String

A string representation of this object.
override

Operators

operator ==(Object other) bool

The equality operator.
inherited