fromEntity static method

Future<MemberCartModel?> fromEntity(
  1. String documentID,
  2. MemberCartEntity? entity
)

Implementation

static Future<MemberCartModel?> fromEntity(
    String documentID, MemberCartEntity? entity) async {
  if (entity == null) return null;
  var counter = 0;
  return MemberCartModel(
    documentID: documentID,
    appId: entity.appId ?? '',
    cartItems: entity.cartItems == null
        ? null
        : List<CartItemModel>.from(
            await Future.wait(entity.cartItems!.map((item) {
            counter++;
            return CartItemModel.fromEntity(counter.toString(), item);
          }).toList())),
  );
}