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[_mediaUrl] as String?;
  String? imageUrl = messageMap[_imageUrl] 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[_createdAt] 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);
}