calculatePriceSingle<double> static method

dynamic calculatePriceSingle<double>(
  1. Data value, {
  2. dynamic currencySymbol,
})

Implementation

static calculatePriceSingle<double>(singleModel.Data value, {currencySymbol}) {

  if (value.hasVariants == false) {
    if (value.pricing?.onSales == false) {
      return getCurrencySymbol(
          currencySymbol ?? "NGN") +
          "" +
          value.pricing!.currentPrice.toString().moneyFormat;
    } else {
      return getCurrencySymbol(
          currencySymbol ?? "NGN") +
          "" +
          value.pricing!.salesPrice.toString().moneyFormat;
    }
  } else {
    List<double> priceList = [];

    for (var i = 0; i < value.variantCombinations!.length; i++) {
      // priceList.add(value.variantCombinations![i]);
      if (value.variantCombinations![i].onSales = true) {
        priceList.add(value.variantCombinations![i].salesPrice.toDouble());
        priceList.sort();
        return getCurrencySymbol(
            currencySymbol ?? "NGN") +
            "" +
            priceList[0].toString().moneyFormat;
      } else {
        priceList.add(value.variantCombinations![i].currentPrice.toDouble());
        priceList.sort();
        return getCurrencySymbol(
            currencySymbol ?? "NGN") +
            "" +
            priceList[0].toString().moneyFormat;
      }
    }
  }
}