Message.fromMap constructor

Message.fromMap(
  1. Map<Object?, Object?> messageMap
)

Implementation

factory Message.fromMap(Map<Object?, Object?> messageMap) {
  String title = messageMap[_TITLE] as String;
  String id = messageMap[_ID] as String;
  String? text = messageMap[_TEXT] as String?;
  String? type = messageMap[_TYPE] as String?;
  String? contentUrl = messageMap[_URL] as String?;
  String? mediaUrl = messageMap[_MEDIA_URL] as String?;
  String? imageUrl = messageMap[_IMAGE_URL] as String?;
  String? htmlText = messageMap[_HTML] as String?;
  bool isShareable = messageMap[_SHAREABLE] as bool? ?? false;
  bool isRead = messageMap[_READ] as bool? ?? false;
  String? timestamp = messageMap[_CREATED_AT] as String?;
  DateTime createdAt;
  if(timestamp != null) {
    createdAt = DateTime.parse(timestamp);
  } else {
    createdAt = DateTime.fromMillisecondsSinceEpoch(0);
  }
  Map<String?, String?>? attributes = (messageMap[_ATTRIBUTES] as Map<Object?, Object?>?)?.cast<String?, String?>();

  return Message._(title, id, text, type, contentUrl, mediaUrl, imageUrl, htmlText, isShareable, isRead, createdAt, attributes);
}