scan to list working fine
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/// A parsed receipt row shown on the review screen.
|
||||
library;
|
||||
|
||||
class LineItem {
|
||||
LineItem({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.price,
|
||||
this.quantity,
|
||||
this.unitPrice,
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String name;
|
||||
final double price;
|
||||
final int? quantity;
|
||||
final double? unitPrice;
|
||||
|
||||
LineItem copyWith({
|
||||
String? id,
|
||||
String? name,
|
||||
double? price,
|
||||
int? quantity,
|
||||
double? unitPrice,
|
||||
bool clearQuantity = false,
|
||||
}) {
|
||||
return LineItem(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
price: price ?? this.price,
|
||||
quantity: clearQuantity ? null : (quantity ?? this.quantity),
|
||||
unitPrice: clearQuantity ? null : (unitPrice ?? this.unitPrice),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/// A product stored after the user confirms a parsed receipt.
|
||||
library;
|
||||
|
||||
class Product {
|
||||
const Product({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.lastPrice,
|
||||
required this.timesSeen,
|
||||
required this.updatedAt,
|
||||
});
|
||||
|
||||
final int id;
|
||||
final String name;
|
||||
final double lastPrice;
|
||||
final int timesSeen;
|
||||
final DateTime updatedAt;
|
||||
|
||||
factory Product.fromMap(Map<String, Object?> map) {
|
||||
return Product(
|
||||
id: map['id']! as int,
|
||||
name: map['name']! as String,
|
||||
lastPrice: (map['last_price']! as num).toDouble(),
|
||||
timesSeen: map['times_seen']! as int,
|
||||
updatedAt: DateTime.parse(map['updated_at']! as String),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user