fromEntityPlus static method
Implementation
static Future<GridModel?> fromEntityPlus(
String documentID, GridEntity? entity,
{String? appId}) async {
if (entity == null) return null;
GridViewModel? gridViewHolder;
if (entity.gridViewId != null) {
try {
gridViewHolder =
await gridViewRepository(appId: appId)!.get(entity.gridViewId);
} on Exception catch (e) {
print('Error whilst trying to initialise gridView');
print('Error whilst retrieving gridView with id ${entity.gridViewId}');
print('Exception: $e');
}
}
var counter = 0;
return GridModel(
documentID: documentID,
appId: entity.appId ?? '',
description: entity.description,
bodyComponents: entity.bodyComponents == null
? null
: List<BodyComponentModel>.from(
await Future.wait(entity.bodyComponents!.map((item) {
counter++;
return BodyComponentModel.fromEntityPlus(counter.toString(), item,
appId: appId);
}).toList())),
gridView: gridViewHolder,
conditions: await StorageConditionsModel.fromEntityPlus(entity.conditions,
appId: appId),
);
}