29 lines
678 B
Dart
29 lines
678 B
Dart
/// 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),
|
|
);
|
|
}
|
|
}
|