removeFromCart method

void removeFromCart(
  1. PaynowCartItem cartItem, {
  2. int? quantity,
})

Implementation

void removeFromCart(PaynowCartItem cartItem, {int? quantity}) {
  if (this.items.containsKey(cartItem)) {
    /// then decreement quantity by 1 if [quantity] is null
    this.items[cartItem] = this.items[cartItem]! - (quantity ?? 1);
    // remove map if it has reached 0 or below
    if (this.items[cartItem]! <= 0) {
      this.items.remove(cartItem);
    }
  }
}