addtocart

This commit is contained in:
2025-01-30 18:59:34 +05:30
parent 12056d7521
commit 48fab4a1c0
21 changed files with 1662 additions and 742 deletions

View File

@@ -0,0 +1,248 @@
// To parse this JSON data, do
//
// final allCartItems = allCartItemsFromJson(jsondynamic);
import 'dart:convert';
import 'package:grocery_app/src/data/allProduct_model.dart';
AllCartItems allCartItemsFromJson(dynamic str) =>
AllCartItems.fromJson(json.decode(str));
dynamic allCartItemsToJson(AllCartItems data) => json.encode(data.toJson());
class AllCartItems {
dynamic id;
dynamic userId;
dynamic subtotal;
DateTime? createdAt;
DateTime? updatedAt;
List<Item>? items;
AllCartItems({
this.id,
this.userId,
this.subtotal,
this.createdAt,
this.updatedAt,
this.items,
});
factory AllCartItems.fromJson(Map<dynamic, dynamic> json) => AllCartItems(
id: json["id"],
userId: json["userId"],
subtotal: json["subtotal"],
createdAt: DateTime.parse(json["createdAt"]),
updatedAt: DateTime.parse(json["updatedAt"]),
items: List<Item>.from(json["items"].map((x) => Item.fromJson(x))),
);
Map<dynamic, dynamic> toJson() => {
"id": id,
"userId": userId,
"subtotal": subtotal,
"createdAt": createdAt,
"updatedAt": updatedAt,
"items": List<dynamic>.from(items!.map((x) => x.toJson())),
};
}
class Item {
dynamic id;
dynamic quantity;
dynamic priceSnapshot;
dynamic cartId;
dynamic productId;
dynamic storeId;
DateTime? createdAt;
DateTime? updatedAt;
Product? product;
Store? store;
Item({
this.id,
this.quantity,
this.priceSnapshot,
this.cartId,
this.productId,
this.storeId,
this.createdAt,
this.updatedAt,
this.product,
this.store,
});
factory Item.fromJson(Map<dynamic, dynamic> json) => Item(
id: json["id"],
quantity: json["quantity"],
priceSnapshot: json["priceSnapshot"],
cartId: json["cartId"],
productId: json["productId"],
storeId: json["storeId"],
createdAt: DateTime.parse(json["createdAt"]),
updatedAt: DateTime.parse(json["updatedAt"]),
product: Product.fromJson(json["product"]),
store: Store.fromJson(json["store"]),
);
Map<dynamic, dynamic> toJson() => {
"id": id,
"quantity": quantity,
"priceSnapshot": priceSnapshot,
"cartId": cartId,
"productId": productId,
"storeId": storeId,
"createdAt": createdAt,
"updatedAt": updatedAt,
"product": product!.toJson(),
"store": store!.toJson(),
};
}
class Category {
dynamic id;
dynamic name;
dynamic description;
dynamic image;
dynamic slug;
dynamic level;
bool? isActive;
DateTime? createdAt;
DateTime? updatedAt;
dynamic parentCategoryId;
dynamic path;
Category({
this.id,
this.name,
this.description,
this.image,
this.slug,
this.level,
this.isActive,
this.createdAt,
this.updatedAt,
this.parentCategoryId,
this.path,
});
factory Category.fromJson(Map<dynamic, dynamic> json) => Category(
id: json["id"],
name: json["name"],
description: json["description"],
image: json["image"],
slug: json["slug"],
level: json["level"],
isActive: json["isActive"],
createdAt: DateTime.parse(json["createdAt"]),
updatedAt: DateTime.parse(json["updatedAt"]),
parentCategoryId: json["parentCategoryId"],
path: json["path"],
);
Map<dynamic, dynamic> toJson() => {
"id": id,
"name": name,
"description": description,
"image": image,
"slug": slug,
"level": level,
"isActive": isActive,
"createdAt": createdAt,
"updatedAt": updatedAt,
"parentCategoryId": parentCategoryId,
"path": path,
};
}
class ProductImage {
dynamic id;
dynamic url;
bool? isDefault;
dynamic productId;
ProductImage({
this.id,
this.url,
this.isDefault,
this.productId,
});
factory ProductImage.fromJson(Map<dynamic, dynamic> json) => ProductImage(
id: json["id"],
url: json["url"],
isDefault: json["isDefault"],
productId: json["productId"],
);
Map<dynamic, dynamic> toJson() => {
"id": id,
"url": url,
"isDefault": isDefault,
"productId": productId,
};
}
class Store {
dynamic id;
dynamic storeName;
dynamic storeDescription;
dynamic officialPhoneNumber;
dynamic storeAddress;
dynamic gstNumber;
dynamic gumastaNumber;
dynamic storePicture;
DateTime? createdAt;
DateTime? updatedAt;
dynamic vendorId;
bool? isActive;
dynamic couponId;
Store({
this.id,
this.storeName,
this.storeDescription,
this.officialPhoneNumber,
this.storeAddress,
this.gstNumber,
this.gumastaNumber,
this.storePicture,
this.createdAt,
this.updatedAt,
this.vendorId,
this.isActive,
this.couponId,
});
factory Store.fromJson(Map<dynamic, dynamic> json) => Store(
id: json["id"],
storeName: json["storeName"],
storeDescription: json["storeDescription"],
officialPhoneNumber: json["officialPhoneNumber"],
storeAddress: json["storeAddress"],
gstNumber: json["gstNumber"],
gumastaNumber: json["gumastaNumber"],
storePicture: json["storePicture"],
createdAt: DateTime.parse(json["createdAt"]),
updatedAt: DateTime.parse(json["updatedAt"]),
vendorId: json["vendorId"],
isActive: json["isActive"],
couponId: json["couponId"],
);
Map<dynamic, dynamic> toJson() => {
"id": id,
"storeName": storeName,
"storeDescription": storeDescription,
"officialPhoneNumber": officialPhoneNumber,
"storeAddress": storeAddress,
"gstNumber": gstNumber,
"gumastaNumber": gumastaNumber,
"storePicture": storePicture,
"createdAt": createdAt,
"updatedAt": updatedAt,
"vendorId": vendorId,
"isActive": isActive,
"couponId": couponId,
};
}