Skip to content

Message

A message (announcement, article or news) shown to participants in the app.

Messages are stored and fetched by a MessageManager, such as CarpResourceManager.

Annotations
  • @JsonSerializable(fieldRename: FieldRename.snake, includeIfNull: false, explicitToJson: true)

Constructors

Message.fromJson

Message.fromJson(
  1. Map<String, dynamic> json
)

Message

Message({
  1. String? id,
  2. MessageType type = MessageType.announcement,
  3. String? title,
  4. String? subTitle,
  5. String? message,
  6. String? url,
  7. String? image,
  8. DateTime? timestamp,
})

Creates a message.

If id is not specified, a UUID is assigned. If timestamp is not specified, the current time is used.

Properties

id

String id
getter/setter pair

ID of the message. A UUID is generated if none is given.

image

String? image
getter/setter pair

The pathname for an image.

This image path can have two forms:

  • URL - if the image path starts with http(s)://... the image is loaded from the internet using the Image.network() constructor.
  • Asset - otherwise, it is assumed that this is the path to a local image asset and the image is loaded from the asset bundle using the Image.asset() constructor.

message

String? message
getter/setter pair

A longer detailed message.

subTitle

String? subTitle
getter/setter pair

A short sub title.

timestamp

DateTime timestamp
getter/setter pair

Creation time. Defaults to the time the message was created.

title

String? title
getter/setter pair

A short title.

type

MessageType type
getter/setter pair

Type of message.

url

String? url
getter/setter pair

A URL to redirect the user to for an online item.

Methods

toJson

Map<String, dynamic> toJson()

toString

String toString()
override

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.