fromEntityPlus static method
Implementation
static Future<ProductModel?> fromEntityPlus(
String documentID, ProductEntity? entity,
{String? appId}) async {
if (entity == null) return null;
ShopModel? shopHolder;
if (entity.shopId != null) {
try {
shopHolder = await shopRepository(appId: appId)!.get(entity.shopId);
} on Exception catch (e) {
print('Error whilst trying to initialise shop');
print('Error whilst retrieving shop with id ${entity.shopId}');
print('Exception: $e');
}
}
var counter = 0;
return ProductModel(
documentID: documentID,
appId: entity.appId ?? '',
title: entity.title,
about: entity.about,
price: entity.price,
weight: entity.weight,
shop: shopHolder,
images: entity.images == null
? null
: List<ProductImageModel>.from(
await Future.wait(entity.images!.map((item) {
counter++;
return ProductImageModel.fromEntityPlus(counter.toString(), item,
appId: appId);
}).toList())),
posSize: await PosSizeModel.fromEntityPlus(entity.posSize, appId: appId),
);
}