removeFromCart method
- String productId
Removes an item from the user's cart in Firestore.
Parameters:
- productId: The ID of the product to be removed.
Returns: A Future<void> that completes when the item is removed.
Implementation
Future<void> removeFromCart(String productId) async {
try {
await _firestore
.collection('carts')
.doc(userId)
.collection('items')
.doc(productId)
.delete();
} catch (e) {
print('Error removing from cart: $e');
}
}