Event class

All data exchanged over SDN is expressed as an "event". Typically each client action (e.g. sending a message) correlates with exactly one event.

Inheritance
Implementers
Available extensions

Constructors

Event({EventStatus status = defaultStatus, required Map<String, dynamic> content, required String type, required String eventId, required String senderId, required DateTime originServerTs, Map<String, dynamic>? unsigned, Map<String, dynamic>? prevContent, String? stateKey, required Room room, SDNEvent? originalSource})
Event.fromJson(Map<String, dynamic> jsonPayload, Room room)
Get a State event from a table row or from the event stream.
factory
Event.fromSDNEvent(SDNEvent sdnEvent, Room room, {EventStatus status = defaultStatus})
factory

Properties

asUser User
no setter
attachmentMimetype String
Gets the mimetype of the attachment of a file event, or a blank string if not present
no setter
attachmentMxcUrl Uri?
Gets the underlying mxc url of an attachment of a file event, or null if not present
no setter
body String
Use this to get the body.
no setter
canRedact bool
Whether the client is allowed to redact this event.
no setter
content Map<String, Object?>
getter/setter pairinherited
eventId String
getter/setter pairinherited
fileSendingStatus FileSendingStatus?
If this event is in Status SENDING and it aims to send a file, then this shows the status of the file sending.
no setter
formattedText String
Returns the formatted boy of this event if it has a formatted body.
no setter
hasAttachment bool
Returns if a file event has an attachment
no setter
hashCode int
The hash code for this object.
no setterinherited
hasThumbnail bool
Returns if a file event has a thumbnail
no setter
infoMap Map
Gets the info map of file events, or a blank map if none present
no setter
isAttachmentEncrypted bool
Returns if a file events attachment is encrypted
no setter
isEventTypeKnown bool
Returns if this is a known event type.
no setter
isRichMessage bool
returns if a message is a rich message
no setter
isThumbnailEncrypted bool
Returns if a file events thumbnail is encrypted
no setter
messageType String
no setter
numberEmotes int
Gets the number of emotes in a given message. This is useful to determine if the emotes should be displayed bigger. If the body contains a reply then it is stripped. WARNING: This does not test if there are only emotes. Use event.onlyEmotes for that!
no setter
onlyEmotes bool
Returns if a given event only has emotes, emojis or whitespace as content. If the body contains a reply then it is stripped. This is useful to determine if stand-alone emotes should be displayed bigger.
no setter
originalSource SDNEvent?
no setter
originServerTs DateTime
getter/setter pairinherited
plaintextBody String
Use this to get a plain-text representation of the event, stripping things like spoilers and thelike. Useful for plain text notifications.
no setter
prevContent Map<String, Object?>?
getter/setter pairinherited
receipts List<Receipt>
Returns a list of Receipt instances for this event.
no setter
redacted bool
no setter
redactedBecause Event?
Optional. The event that redacted this event, if any. Otherwise null.
no setter
redacts String?
getter/setter pairinherited
relationshipEventId String?
Get the event ID that this relationship will reference. null if there is none
no setter
relationshipType String?
Get the relationship type of an event. null if there is none
no setter
room Room
The room this event belongs to. May be null.
final
roomId String?
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sender User
no setter
senderFromMemoryOrFallback User
no setter
senderId String
getter/setter pairinherited
stateKey String?
getter/setter pairinherited
stateKeyUser User?
no setter
status EventStatus
The status of this event.
getter/setter pair
text String
Returns the body of this event if it has a body.
no setter
thumbnailInfoMap Map
Gets the thumbnail info map of file events, or a blank map if nonepresent
no setter
thumbnailMimetype String
Gets the mimetype of the thumbnail of a file event, or a blank string if not present
no setter
thumbnailMxcUrl Uri?
Gets the underlying mxc url of a thumbnail of a file event, or null if not present
no setter
type String
getter/setter pairinherited
unsigned Map<String, Object?>?
getter/setter pairinherited

Methods

aggregatedEvents(Timeline timeline, String type) Set<Event>
Get all the aggregated event objects for a given type. To be able to do this you have to pass a timeline
attachmentOrThumbnailMxcUrl({bool getThumbnail = false}) Uri?
Gets the mxc url of an attachment/thumbnail of a file event, taking sizes into account, or null if not present
calcLocalizedBody(SDNLocalizations i18n, {bool withSenderNamePrefix = false, bool hideReply = false, bool hideEdit = false, bool plaintextBody = false, bool removeMarkdown = false}) Future<String>
Returns a localized String representation of this event. For a room list you may find withSenderNamePrefix useful. Set hideReply to crop all lines starting with '>'. With plaintextBody it'll use the plaintextBody instead of the normal body. removeMarkdown allow to remove the markdown formating from the event body. Usefull form message preview or notifications text.
calcLocalizedBodyFallback(SDNLocalizations i18n, {bool withSenderNamePrefix = false, bool hideReply = false, bool hideEdit = false, bool plaintextBody = false, bool removeMarkdown = false}) String
Works similar to calcLocalizedBody() but does not wait for the sender user to be fetched. If it is not in the cache it will just use the fallback and display the localpart of the MXID according to the values of formatLocalpart and mxidLocalPartFallback in the Client class.
calcUnlocalizedBody({bool hideReply = false, bool hideEdit = false, bool plaintextBody = false, bool removeMarkdown = false}) String
Calculating the body of an event regardless of localization.
downloadAndDecryptAttachment({bool getThumbnail = false, Future<Uint8List> downloadCallback(Uri)?}) Future<SDNFile>
Downloads (and decrypts if necessary) the attachment of this event and returns it as a SDNFile. If this event doesn't contain an attachment, this throws an error. Set getThumbnail to true to download the thumbnail instead.
fetchSenderUser() Future<User?>
Requests the user object of the sender of this event.
getAttachmentUrl({bool getThumbnail = false, bool useThumbnailMxcUrl = false, double width = 800.0, double height = 800.0, ThumbnailMethod method = ThumbnailMethod.scale, int minNoThumbSize = _minNoThumbSize, bool animated = false}) Uri?
Gets the attachment https URL to display in the timeline, taking into account if the original image is tiny. Returns null for encrypted rooms, if the image can't be fetched via http url or if the event does not contain an attachment. Set getThumbnail to true to fetch the thumbnail, set width, height and method for the respective thumbnailing properties. minNoThumbSize is the minimum size that an original image may be to not fetch its thumbnail, defaults to 80k useThumbnailMxcUrl says weather to use the mxc url of the thumbnail, rather than the original attachment. animated says weather the thumbnail is animated
getDisplayEvent(Timeline timeline) Event
Fetches the event to be rendered, taking into account all the edits and the like. It needs a timeline for that.
getLocalizedBody(SDNLocalizations i18n, {bool withSenderNamePrefix = false, bool hideReply = false, bool hideEdit = false, bool plaintextBody = false, bool removeMarkdown = false}) String
getReplyEvent(Timeline timeline) Future<Event?>
Searches for the reply event in the given timeline.
hasAggregatedEvents(Timeline timeline, String type) bool
Get whether this event has aggregated events from a certain type To be able to do that you need to pass a timeline
isAttachmentInLocalStore({bool getThumbnail = false}) Future<bool>
Returns if an attachment is in the local store
matchesEventOrTransactionId(String? search) bool
returns if this event matches the passed event or transaction id
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
redactEvent({String? reason, String? txid}) Future<String?>
Redacts this event. Throws ErrorResponse on error.
remove() Future<bool>
Removes this event if the status is sending, error or removed. This event will just be removed from the database and the timelines. Returns false if not removed.
requestKey() Future<void>
If this event is encrypted and the decryption was not successful because the session is unknown, this requests the session key from other devices in the room. If the event is not encrypted or the decryption failed because of a different error, this throws an exception.
sendAgain({String? txid}) Future<String?>
Try to send this event again. Only works with events of status -1.
setRedactionEvent(Event redactedBecause) → void
toJson() Map<String, dynamic>
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

getMapFromPayload(Object? payload) Map<String, dynamic>

Constants

defaultStatus → const EventStatus
textOnlyMessageTypes → const Set<String>