fromEntity static method

Future<MemberModel?> fromEntity(
  1. String documentID,
  2. MemberEntity? entity
)

Implementation

static Future<MemberModel?> fromEntity(
    String documentID, MemberEntity? entity) async {
  if (entity == null) return null;
  var counter = 0;
  return MemberModel(
    documentID: documentID,
    name: entity.name,
    subscriptions: entity.subscriptions == null
        ? null
        : List<MemberSubscriptionModel>.from(
            await Future.wait(entity.subscriptions!.map((item) {
            counter++;
            return MemberSubscriptionModel.fromEntity(
                counter.toString(), item);
          }).toList())),
    subscriptionsAsStrArr: entity.subscriptionsAsStrArr,
    photoURL: entity.photoURL,
    shipStreet1: entity.shipStreet1,
    shipStreet2: entity.shipStreet2,
    shipCity: entity.shipCity,
    shipState: entity.shipState,
    postcode: entity.postcode,
    country: entity.country,
    invoiceSame: entity.invoiceSame,
    invoiceStreet1: entity.invoiceStreet1,
    invoiceStreet2: entity.invoiceStreet2,
    invoiceCity: entity.invoiceCity,
    invoiceState: entity.invoiceState,
    invoicePostcode: entity.invoicePostcode,
    invoiceCountry: entity.invoiceCountry,
    email: entity.email,
    isAnonymous: entity.isAnonymous,
  );
}