File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ class OrderModel {
2+ final String orderId;
3+ final String productId;
4+ final String productName;
5+ final int price;
6+ final DateTime createdAt;
7+ final String status;
8+
9+ OrderModel ({
10+ required this .orderId,
11+ required this .productId,
12+ required this .productName,
13+ required this .price,
14+ required this .createdAt,
15+ required this .status,
16+ });
17+
18+ Map <String , dynamic > toMap () {
19+ return {
20+ 'orderId' : orderId, // ✅ FIX
21+ 'productId' : productId,
22+ 'productName' : productName,
23+ 'price' : price,
24+ 'createdAt' : createdAt,
25+ 'status' : status,
26+ };
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ class Product {
2+ final String id;
3+ final String name;
4+ final int price;
5+ final int stock;
6+ final String imageUrl;
7+ final bool trending;
8+
9+ Product ({
10+ required this .id,
11+ required this .name,
12+ required this .price,
13+ required this .stock,
14+ required this .imageUrl,
15+ required this .trending,
16+ });
17+
18+ factory Product .fromMap (String id, Map <String , dynamic > data) {
19+ return Product (
20+ id: id,
21+ name: data['name' ],
22+ price: data['price' ],
23+ stock: data['stock' ],
24+ imageUrl: data['imageUrl' ],
25+ trending: data['trending' ] ?? false ,
26+ );
27+ }
28+
29+ Map <String , dynamic > toMap () {
30+ return {
31+ 'name' : name,
32+ 'price' : price,
33+ 'stock' : stock,
34+ 'imageUrl' : imageUrl,
35+ 'trending' : trending,
36+ };
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments