fastCalc method

MoneyFormatter fastCalc({
  1. required FastCalcType type,
  2. required double amount,
})

returns FlutterMoneyFormatter after calculating amount.

Implementation

MoneyFormatter fastCalc(
    {required FastCalcType type, required double amount}) {
  switch (type) {
    case FastCalcType.addition:
      this.amount += amount;
      break;

    case FastCalcType.substraction:
      this.amount -= amount;
      break;

    case FastCalcType.multiplication:
      this.amount *= amount;
      break;

    case FastCalcType.division:
      this.amount /= amount;
      break;

    case FastCalcType.percentageAddition:
      this.amount += (amount / 100) * this.amount;
      break;

    case FastCalcType.percentageSubstraction:
      this.amount -= (amount / 100) * this.amount;
      break;

    default:
      throw "Unknown calculation type.";
  }

  return this;
}