fromMap static method

PostCommentEntity? fromMap(
  1. Object? o, {
  2. Map<String, String>? newDocumentIds,
})

Implementation

static PostCommentEntity? fromMap(Object? o,
    {Map<String, String>? newDocumentIds}) {
  if (o == null) return null;
  var map = o as Map<String, dynamic>;

  var memberMediaFromMap = map['memberMedia'];
  List<MemberMediumEntity> memberMediaList;
  if (memberMediaFromMap != null) {
    memberMediaList = (map['memberMedia'] as List<dynamic>)
        .map((dynamic item) => MemberMediumEntity.fromMap(item as Map,
            newDocumentIds: newDocumentIds)!)
        .toList();
  } else {
    memberMediaList = [];
  }

  return PostCommentEntity(
    postId: map['postId'],
    postCommentId: map['postCommentId'],
    memberId: map['memberId'],
    timestamp: map['timestamp'] == null
        ? null
        : (map['timestamp'] as Timestamp).millisecondsSinceEpoch,
    appId: map['appId'],
    comment: map['comment'],
    likes: int.tryParse(map['likes'].toString()),
    dislikes: int.tryParse(map['dislikes'].toString()),
    memberMedia: memberMediaList,
  );
}