28 lines
506 B
Dart
28 lines
506 B
Dart
// lib/models/cart_item.dart
|
|
import 'package:cheminova/models/product_model1.dart';
|
|
|
|
class CartItem {
|
|
final Product product;
|
|
int quantity;
|
|
|
|
CartItem({
|
|
required this.product,
|
|
this.quantity = 1,
|
|
});
|
|
|
|
// Method to increase quantity
|
|
void increaseQuantity() {
|
|
quantity++;
|
|
}
|
|
|
|
// Method to decrease quantity
|
|
void decreaseQuantity() {
|
|
if (quantity > 1) {
|
|
quantity--;
|
|
}
|
|
}
|
|
|
|
// Method to get total price of this item
|
|
int get totalPrice => product.price * quantity;
|
|
}
|