PersistentShoppingCart class
The main class for interacting with the persistent shopping cart.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addToCart(
PersistentShoppingCartItem cartItem) → Future< void> - Adds a PersistentShoppingCartItem to the shopping cart.
-
calculateTotalPrice(
) → double - Calculates the total price of all items in the shopping cart.
-
clearCart(
) → void - Clears all items from the shopping cart.
-
decrementCartItemQuantity(
String productId) → Future< void> - Decrements the quantity of a cart item.
-
getCartData(
) → Map< String, dynamic> - Retrieves the cart data including items and total price.
-
getCartItemCount(
) → int - Gets the total number of items in the shopping cart.
-
incrementCartItemQuantity(
String productId) → Future< void> - Increments the quantity of a cart item.
-
init(
) → Future< void> - Initializes Hive and opens the cart box.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeFromCart(
String productId) → Future< bool> - Removes a product from the shopping cart.
-
showAndUpdateCartItemWidget(
{required Widget inCartWidget, required Widget notInCartWidget, required PersistentShoppingCartItem product}) → Widget - Displays an icon button based on whether a product is in the cart or not.
-
showCartItemCountWidget(
{required Widget cartItemCountWidgetBuilder(int itemCount)}) → Widget - Displays the current cart item count using the provided widget builder.
-
showCartItems(
{required Widget cartItemsBuilder(BuildContext context, List< PersistentShoppingCartItem> cartItems)}) → Widget - Displays the list of cart items using the provided builder. Define whether you want to display items in a ListView, GridView, etc.
-
showTotalAmountWidget(
{required Widget cartTotalAmountWidgetBuilder(double totalAmount)}) → Widget - Displays the total amount in the cart using the provided widget builder.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited