fromEntity static method

Future<FeedMenuModel?> fromEntity(
  1. String documentID,
  2. FeedMenuEntity? entity
)

Implementation

static Future<FeedMenuModel?> fromEntity(
    String documentID, FeedMenuEntity? entity) async {
  if (entity == null) return null;
  var counter = 0;
  return FeedMenuModel(
    documentID: documentID,
    appId: entity.appId ?? '',
    description: entity.description,
    bodyComponentsCurrentMember: entity.bodyComponentsCurrentMember == null
        ? null
        : List<LabelledBodyComponentModel>.from(
            await Future.wait(entity.bodyComponentsCurrentMember!.map((item) {
            counter++;
            return LabelledBodyComponentModel.fromEntity(
                counter.toString(), item);
          }).toList())),
    bodyComponentsOtherMember: entity.bodyComponentsOtherMember == null
        ? null
        : List<LabelledBodyComponentModel>.from(
            await Future.wait(entity.bodyComponentsOtherMember!.map((item) {
            counter++;
            return LabelledBodyComponentModel.fromEntity(
                counter.toString(), item);
          }).toList())),
    itemColor: await RgbModel.fromEntity(entity.itemColor),
    selectedItemColor: await RgbModel.fromEntity(entity.selectedItemColor),
    backgroundOverride:
        await BackgroundModel.fromEntity(entity.backgroundOverride),
    conditions: await StorageConditionsModel.fromEntity(entity.conditions),
  );
}