fromEntity static method

Future<ProductModel?> fromEntity(
  1. String documentID,
  2. ProductEntity? entity
)

Implementation

static Future<ProductModel?> fromEntity(
    String documentID, ProductEntity? entity) async {
  if (entity == null) return null;
  var counter = 0;
  return ProductModel(
    documentID: documentID,
    appId: entity.appId ?? '',
    title: entity.title,
    about: entity.about,
    price: entity.price,
    weight: entity.weight,
    images: entity.images == null
        ? null
        : List<ProductImageModel>.from(
            await Future.wait(entity.images!.map((item) {
            counter++;
            return ProductImageModel.fromEntity(counter.toString(), item);
          }).toList())),
    posSize: await PosSizeModel.fromEntity(entity.posSize),
  );
}