init
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
class Product {
|
||||
final String id;
|
||||
final String name;
|
||||
final String category;
|
||||
final int stockQuantity;
|
||||
final int lowStockThreshold;
|
||||
final int priceInCents;
|
||||
final String? imagePath;
|
||||
final bool active;
|
||||
|
||||
const Product({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.category,
|
||||
required this.stockQuantity,
|
||||
required this.lowStockThreshold,
|
||||
required this.priceInCents,
|
||||
this.imagePath,
|
||||
this.active = true,
|
||||
});
|
||||
|
||||
bool get isLowStock => stockQuantity <= lowStockThreshold;
|
||||
|
||||
String get formattedPrice {
|
||||
final euros = priceInCents / 100;
|
||||
|
||||
return '€${euros.toStringAsFixed(2)}';
|
||||
}
|
||||
|
||||
Product copyWith({
|
||||
String? id,
|
||||
String? name,
|
||||
String? category,
|
||||
int? stockQuantity,
|
||||
int? lowStockThreshold,
|
||||
int? priceInCents,
|
||||
String? imagePath,
|
||||
bool? active,
|
||||
}) {
|
||||
return Product(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
category: category ?? this.category,
|
||||
stockQuantity: stockQuantity ?? this.stockQuantity,
|
||||
lowStockThreshold: lowStockThreshold ?? this.lowStockThreshold,
|
||||
priceInCents: priceInCents ?? this.priceInCents,
|
||||
imagePath: imagePath ?? this.imagePath,
|
||||
active: active ?? this.active,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user