fromEntity static method
Implementation
static Future<PostModel?> fromEntity(
String documentID, PostEntity? entity) async {
if (entity == null) return null;
var counter = 0;
return PostModel(
documentID: documentID,
authorId: entity.authorId ?? '',
timestamp: entity.timestamp == null
? null
: DateTime.fromMillisecondsSinceEpoch((entity.timestamp as int)),
appId: entity.appId ?? '',
feedId: entity.feedId,
postAppId: entity.postAppId,
postPageId: entity.postPageId,
pageParameters: entity.pageParameters,
html: entity.html,
description: entity.description,
likes: entity.likes,
dislikes: entity.dislikes,
accessibleByGroup: toPostAccessibleByGroup(entity.accessibleByGroup),
accessibleByMembers: entity.accessibleByMembers,
readAccess: entity.readAccess,
archived: toPostArchiveStatus(entity.archived),
externalLink: entity.externalLink,
memberMedia: entity.memberMedia == null
? null
: List<MemberMediumContainerModel>.from(
await Future.wait(entity.memberMedia!.map((item) {
counter++;
return MemberMediumContainerModel.fromEntity(
counter.toString(), item);
}).toList())),
);
}