calculateDiscountValue static method

String calculateDiscountValue(
  1. String originalPrice,
  2. String discountPrice
)

Implementation

static String calculateDiscountValue(
    String originalPrice, String discountPrice) {
  try {
    double discountPerc =
      ((1 -  (double.parse(discountPrice) / double.parse(originalPrice))) * 100).ceilToDouble();

    if((discountPerc.isNegative) || (discountPerc == 0)){
      return 'N/A';
    }
    else{
      return discountPerc.text;
    }

  } catch (e) {
    return 'N/A';
  }
}