fromEntityPlus static method
Implementation
static Future<SectionModel?> fromEntityPlus(
String documentID, SectionEntity? entity,
{String? appId}) async {
if (entity == null) return null;
PlatformMediumModel? imageHolder;
if (entity.imageId != null) {
try {
imageHolder =
await platformMediumRepository(appId: appId)!.get(entity.imageId);
} on Exception catch (e) {
print('Error whilst trying to initialise image');
print(
'Error whilst retrieving platformMedium with id ${entity.imageId}');
print('Exception: $e');
}
}
var counter = 0;
return SectionModel(
documentID: documentID,
title: entity.title,
description: entity.description,
image: imageHolder,
imagePositionRelative:
toRelativeImagePosition(entity.imagePositionRelative),
imageAlignment: toSectionImageAlignment(entity.imageAlignment),
imageWidth: entity.imageWidth,
links: entity.links == null
? null
: List<LinkModel>.from(await Future.wait(entity.links!.map((item) {
counter++;
return LinkModel.fromEntityPlus(counter.toString(), item,
appId: appId);
}).toList())),
);
}