runable
This commit is contained in:
50
lib/features/home/domain/entities/cart_item.dart
Normal file
50
lib/features/home/domain/entities/cart_item.dart
Normal file
@@ -0,0 +1,50 @@
|
||||
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,
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user