51 lines
1.1 KiB
Dart
51 lines
1.1 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
|
|
/// Cart item domain entity
|
|
class CartItem extends Equatable {
|
|
final String productId;
|
|
final String productName;
|
|
final double price;
|
|
final int quantity;
|
|
final String? imageUrl;
|
|
final DateTime addedAt;
|
|
|
|
const CartItem({
|
|
required this.productId,
|
|
required this.productName,
|
|
required this.price,
|
|
required this.quantity,
|
|
this.imageUrl,
|
|
required this.addedAt,
|
|
});
|
|
|
|
double get total => price * quantity;
|
|
|
|
CartItem copyWith({
|
|
String? productId,
|
|
String? productName,
|
|
double? price,
|
|
int? quantity,
|
|
String? imageUrl,
|
|
DateTime? addedAt,
|
|
}) {
|
|
return CartItem(
|
|
productId: productId ?? this.productId,
|
|
productName: productName ?? this.productName,
|
|
price: price ?? this.price,
|
|
quantity: quantity ?? this.quantity,
|
|
imageUrl: imageUrl ?? this.imageUrl,
|
|
addedAt: addedAt ?? this.addedAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [
|
|
productId,
|
|
productName,
|
|
price,
|
|
quantity,
|
|
imageUrl,
|
|
addedAt,
|
|
];
|
|
}
|