fixes before build
This commit is contained in:
@@ -22,6 +22,14 @@ class LineItem {
|
||||
/// Negative amount when a discount was folded into [price].
|
||||
final double discount;
|
||||
|
||||
bool get hasDiscount => discount != 0;
|
||||
|
||||
/// List price before a folded discount. Equals [price] when there is none.
|
||||
double get originalPrice {
|
||||
if (!hasDiscount) return price;
|
||||
return ((price - discount) * 100).round() / 100;
|
||||
}
|
||||
|
||||
LineItem copyWith({
|
||||
String? id,
|
||||
String? name,
|
||||
|
||||
@@ -72,4 +72,4 @@ class Product {
|
||||
}
|
||||
}
|
||||
|
||||
enum ProductSort { name, preferred }
|
||||
enum ProductSort { name, preferred, start }
|
||||
|
||||
@@ -7,6 +7,7 @@ class ShoppingList {
|
||||
required this.name,
|
||||
required this.itemCount,
|
||||
required this.checkedCount,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
});
|
||||
|
||||
@@ -14,6 +15,7 @@ class ShoppingList {
|
||||
final String name;
|
||||
final int itemCount;
|
||||
final int checkedCount;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
|
||||
factory ShoppingList.fromMap(Map<String, Object?> map) {
|
||||
@@ -22,6 +24,9 @@ class ShoppingList {
|
||||
name: map['name']! as String,
|
||||
itemCount: (map['item_count'] as num?)?.toInt() ?? 0,
|
||||
checkedCount: (map['checked_count'] as num?)?.toInt() ?? 0,
|
||||
createdAt: DateTime.parse(
|
||||
(map['created_at'] ?? map['updated_at'])! as String,
|
||||
),
|
||||
updatedAt: DateTime.parse(map['updated_at']! as String),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,12 +9,14 @@ class Supermarket {
|
||||
required this.name,
|
||||
required this.colorValue,
|
||||
this.sortOrder = 0,
|
||||
this.bonusImagePath,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final String name;
|
||||
final int colorValue;
|
||||
final int sortOrder;
|
||||
final String? bonusImagePath;
|
||||
|
||||
Color get color => Color(colorValue);
|
||||
|
||||
@@ -24,6 +26,7 @@ class Supermarket {
|
||||
name: map['name']! as String,
|
||||
colorValue: map['color']! as int,
|
||||
sortOrder: map['sort_order'] as int? ?? 0,
|
||||
bonusImagePath: map['bonus_image_path'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -32,12 +35,17 @@ class Supermarket {
|
||||
String? name,
|
||||
int? colorValue,
|
||||
int? sortOrder,
|
||||
String? bonusImagePath,
|
||||
bool clearBonusImage = false,
|
||||
}) {
|
||||
return Supermarket(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
colorValue: colorValue ?? this.colorValue,
|
||||
sortOrder: sortOrder ?? this.sortOrder,
|
||||
bonusImagePath: clearBonusImage
|
||||
? null
|
||||
: (bonusImagePath ?? this.bonusImagePath),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user