Message.fromMap constructor

Message.fromMap(
  1. Map<String, dynamic> map
)

Implementation

factory Message.fromMap(Map<String, dynamic> map) {
  return Message(
    id: map['id'] != null ? map['id'] as String : null,
    text: map['text'] != null ? map['text'] as String : null,
    imgUrl: map['imgUrl'] != null ? map['imgUrl'] as String : null,
    videoUrl: map['videoUrl'] != null ? map['videoUrl'] as String : null,
    audioUrl: map['audioUrl'] != null ? map['audioUrl'] as String : null,
    type: MessageType.values.firstWhereOrNull(
      (type) => type.toString().split('.').last == map['value'],
    ),
    timestamp: map['timestamp'] != null
        ? DateTime.fromMillisecondsSinceEpoch(map['timestamp'] as int)
        : null,
    isMe: map['isMe'] as bool,
  );
}