decrementItemFromCart method Null safety

dynamic decrementItemFromCart(
  1. int index
)

This function is used to decrement the item quantity from cart

Implementation

decrementItemFromCart(int index) {
  if (_cartItemList[index].quantity > 1) {
    _cartItemList[index].quantity = --_cartItemList[index].quantity;
    _cartItemList[index].subTotal =
        (_cartItemList[index].quantity * _cartItemList[index].unitPrice)
            .roundToDouble();
  } else {
    _cartItemList.removeAt(index);
    return CartResponseWrapper(true, _removedMessage, _cartItemList);
    // return true;
  }
  return CartResponseWrapper(true, _removedMessage, _cartItemList);
}