copyWith method
Returns a copy of this Item object with the given fields replaced by new values.
This can be useful when you want to create a modified version of an existing item without changing the original object.
Implementation
Item copyWith({
String? name,
int? quantity,
double? price,
String? category,
}) {
return Item(
name: name ?? this.name,
quantity: quantity ?? this.quantity,
price: price ?? this.price,
category: (category ?? this.category).toLowerCase(),
);
}