fromEntity static method

Future<PostCommentModel?> fromEntity(
  1. String documentID,
  2. PostCommentEntity? entity
)

Implementation

static Future<PostCommentModel?> fromEntity(
    String documentID, PostCommentEntity? entity) async {
  if (entity == null) return null;
  var counter = 0;
  return PostCommentModel(
    documentID: documentID,
    postId: entity.postId,
    postCommentId: entity.postCommentId,
    memberId: entity.memberId,
    timestamp: entity.timestamp == null
        ? null
        : DateTime.fromMillisecondsSinceEpoch((entity.timestamp as int)),
    appId: entity.appId ?? '',
    comment: entity.comment,
    likes: entity.likes,
    dislikes: entity.dislikes,
    memberMedia: entity.memberMedia == null
        ? null
        : List<MemberMediumModel>.from(
            await Future.wait(entity.memberMedia!.map((item) {
            counter++;
            return MemberMediumModel.fromEntity(counter.toString(), item);
          }).toList())),
  );
}