3 changed files with 40 additions and 13 deletions
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
import 'package:flutter/foundation.dart'; |
||||
import 'package:thesis_shop/models/product.dart'; |
||||
|
||||
@immutable |
||||
class CartItem { |
||||
final Product product; |
||||
final int amount; |
||||
|
||||
double get totalPrice => product.price * amount; |
||||
String get totalPriceAsString => totalPrice.toStringAsFixed(2); |
||||
|
||||
const CartItem({required this.product, required this.amount}) |
||||
: assert(amount >= 0); |
||||
} |
Loading…
Reference in new issue