fromEntity static method

Future<SectionModel?> fromEntity(
  1. String documentID,
  2. SectionEntity? entity
)

Implementation

static Future<SectionModel?> fromEntity(
    String documentID, SectionEntity? entity) async {
  if (entity == null) return null;
  var counter = 0;
  return SectionModel(
    documentID: documentID,
    title: entity.title,
    description: entity.description,
    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.fromEntity(counter.toString(), item);
          }).toList())),
  );
}