Message.fromList constructor

Message.fromList(
  1. List data
)

Creates a Message instance from a list of objects received from the broadcast stream of the event channel.

data should be a list where:

  • data0: message body (String)
  • data1: sender address (String)
  • data2: timestamp in milliseconds since epoch (String or int)

Implementation

factory Message.fromList(List<dynamic> data) {
  return Message(
    body: data[0] as String,
    sender: data[1] as String,
    timeReceived: DateTime.fromMillisecondsSinceEpoch(
      int.parse(data[2].toString()),
    ),
  );
}