addToCart method

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

Adding PaynowCartItems to Payment.items quantity

Implementation

void addToCart(PaynowCartItem cartItem, {int? quantity}) {
  if (this.items.containsKey(cartItem)) {
    /// then increment quantity by 1 if [quantity] is null
    this.items[cartItem] = this.items[cartItem]! + (quantity ?? 1);
  } else {
    /// Add new item to cart with initial quantity of 1 if [quantity] is null
    this.items[cartItem] = quantity ?? 1;
  }
}