CartProvider class Data
A CartProvider class that represents a shopping cart for PurchasableFood items.
The CartProvider class is a ChangeNotifier, which means that it can notify its listeners when the contents of the cart are modified by calling notifyListeners. This can be useful for updating the UI in response to changes to the cart.
The CartProvider class maintains a list of PurchasableFood items that have been added to the cart. It provides methods for adding, removing, and clearing items from the cart, as well as checking whether a particular item is already in the cart.
- Inheritance
-
- Object
- ChangeNotifier
- CartProvider
Constructors
Properties
- count → int
-
Returns the number of PurchasableFood items in the cart.
read-only
- hashCode → int
-
The hash code for this object.
read-onlyinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
read-onlyinherited
-
items
→ List<
PurchasableFood> -
Returns a list of
PurchasableFood
items that have been added to the cart.read-only - runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
Methods
-
add(
PurchasableFood foodItem, BuildContext context) → void - Adds a PurchasableFood item to the cart.
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
clear(
) → void - Clears the cart of all PurchasableFood items.
-
contains(
PurchasableFood foodItem) → bool - Returns true if the cart contains the specified PurchasableFood item, false otherwise.
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
remove(
PurchasableFood foodItem) → void - Removes a PurchasableFood item from the cart.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited