QProduct constructor
QProduct(
- String qonversionId,
- String? storeId,
- String? basePlanId,
- SkuDetailsWrapper? skuDetails,
- QProductStoreDetails? storeDetails,
- SKProductWrapper? skProduct,
- String? offeringId,
- QSubscriptionPeriod? subscriptionPeriod,
- QSubscriptionPeriod? trialPeriod,
- QProductType type,
- String? prettyPrice,
Implementation
QProduct(
this.qonversionId,
this.storeId,
this.basePlanId,
this.skuDetails,
this.storeDetails,
this.skProduct,
this.offeringId,
this.subscriptionPeriod,
this.trialPeriod,
this.type,
this.prettyPrice,
) {
final skuDetails = this.skuDetails;
final storeDetails = this.storeDetails;
final skProduct = this.skProduct;
if (skProduct != null) {
storeTitle = skProduct.localizedTitle;
storeDescription = skProduct.localizedDescription;
currencyCode = skProduct.priceLocale?.currencyCode;
price = double.tryParse(skProduct.price) ?? null;
final SKProductDiscountWrapper? introPrice = skProduct.introductoryPrice;
final String? currencySymbol = introPrice?.priceLocale?.currencySymbol;
if (introPrice != null && currencySymbol != null) {
prettyIntroductoryPrice = currencySymbol + introPrice.price;
}
} else {
var priceMicros;
if (skuDetails != null) {
storeTitle = skuDetails.title;
storeDescription = skuDetails.description;
priceMicros = skuDetails.priceAmountMicros;
currencyCode = skuDetails.priceCurrencyCode;
final String? introPrice = skuDetails.introductoryPrice;
if (introPrice != null && introPrice.isEmpty) {
prettyIntroductoryPrice = null;
} else {
prettyIntroductoryPrice = introPrice;
}
}
if (storeDetails != null) {
storeTitle = storeDetails.title;
storeDescription = storeDetails.description;
final QProductOfferDetails? defaultOffer = storeDetails.defaultSubscriptionOfferDetails;
final QProductInAppDetails? inAppOffer = storeDetails.inAppOfferDetails;
if (defaultOffer != null) {
priceMicros = defaultOffer.basePlan?.price.priceAmountMicros;
currencyCode = defaultOffer.basePlan?.price.priceCurrencyCode;
prettyIntroductoryPrice = defaultOffer.introPhase?.price.formattedPrice;
} else if (inAppOffer != null) {
priceMicros = inAppOffer.price.priceAmountMicros;
currencyCode = inAppOffer.price.priceCurrencyCode;
prettyIntroductoryPrice = null;
}
}
price = priceMicros == null
? null
: priceMicros / Constants.skuDetailsPriceRatio;
}
}