addtocart
This commit is contained in:
@@ -1,3 +1,253 @@
|
||||
// // 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,
|
||||
// };
|
||||
// }
|
||||
|
||||
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final allCartItems = allCartItemsFromJson(jsondynamic);
|
||||
@@ -6,73 +256,72 @@ import 'dart:convert';
|
||||
|
||||
import 'package:grocery_app/src/data/allProduct_model.dart';
|
||||
|
||||
AllCartItems allCartItemsFromJson(dynamic str) =>
|
||||
AllCartItems.fromJson(json.decode(str));
|
||||
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;
|
||||
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,
|
||||
});
|
||||
AllCartItems({
|
||||
this.id,
|
||||
this.userId,
|
||||
this.subtotal,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.items,
|
||||
});
|
||||
|
||||
factory AllCartItems.fromJson(Map<dynamic, dynamic> json) => AllCartItems(
|
||||
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() => {
|
||||
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;
|
||||
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,
|
||||
});
|
||||
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(
|
||||
factory Item.fromJson(Map<dynamic, dynamic> json) => Item(
|
||||
id: json["id"],
|
||||
quantity: json["quantity"],
|
||||
priceSnapshot: json["priceSnapshot"],
|
||||
@@ -83,9 +332,9 @@ class Item {
|
||||
updatedAt: DateTime.parse(json["updatedAt"]),
|
||||
product: Product.fromJson(json["product"]),
|
||||
store: Store.fromJson(json["store"]),
|
||||
);
|
||||
);
|
||||
|
||||
Map<dynamic, dynamic> toJson() => {
|
||||
Map<dynamic, dynamic> toJson() => {
|
||||
"id": id,
|
||||
"quantity": quantity,
|
||||
"priceSnapshot": priceSnapshot,
|
||||
@@ -96,37 +345,149 @@ class Item {
|
||||
"updatedAt": updatedAt,
|
||||
"product": product!.toJson(),
|
||||
"store": store!.toJson(),
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// class Product {
|
||||
// dynamic id;
|
||||
// dynamic name;
|
||||
// dynamic description;
|
||||
// dynamic additionalInfo;
|
||||
// dynamic brand;
|
||||
// dynamic basePrice;
|
||||
// dynamic discountPrice;
|
||||
// int stock;
|
||||
// int quantity;
|
||||
// dynamic unit;
|
||||
// dynamic slug;
|
||||
// dynamic averageRating;
|
||||
// bool isInStock;
|
||||
// bool isActive;
|
||||
// DateTime createdAt;
|
||||
// DateTime updatedAt;
|
||||
// dynamic storeId;
|
||||
// dynamic categoryId;
|
||||
// dynamic productTypeId;
|
||||
// dynamic timeSlotId;
|
||||
// List<ProductImage> productImages;
|
||||
// Category category;
|
||||
// List<ProductTag> productTags;
|
||||
// List<dynamic> zones;
|
||||
// List<dynamic> productReview;
|
||||
|
||||
// Product({
|
||||
// this.id,
|
||||
// this.name,
|
||||
// this.description,
|
||||
// this.additionalInfo,
|
||||
// this.brand,
|
||||
// this.basePrice,
|
||||
// this.discountPrice,
|
||||
// this.stock,
|
||||
// this.quantity,
|
||||
// this.unit,
|
||||
// this.slug,
|
||||
// this.averageRating,
|
||||
// this.isInStock,
|
||||
// this.isActive,
|
||||
// this.createdAt,
|
||||
// this.updatedAt,
|
||||
// this.storeId,
|
||||
// this.categoryId,
|
||||
// this.productTypeId,
|
||||
// this.timeSlotId,
|
||||
// this.productImages,
|
||||
// this.category,
|
||||
// this.productTags,
|
||||
// this.zones,
|
||||
// this.productReview,
|
||||
// });
|
||||
|
||||
// factory Product.fromJson(Map<dynamic, dynamic> json) => Product(
|
||||
// id: json["id"],
|
||||
// name: json["name"],
|
||||
// description: json["description"],
|
||||
// additionalInfo: json["additionalInfo"],
|
||||
// brand: json["brand"],
|
||||
// basePrice: json["basePrice"],
|
||||
// discountPrice: json["discountPrice"],
|
||||
// stock: json["stock"],
|
||||
// quantity: json["quantity"],
|
||||
// unit: json["unit"],
|
||||
// slug: json["slug"],
|
||||
// averageRating: json["averageRating"],
|
||||
// isInStock: json["isInStock"],
|
||||
// isActive: json["isActive"],
|
||||
// createdAt: DateTime.parse(json["createdAt"]),
|
||||
// updatedAt: DateTime.parse(json["updatedAt"]),
|
||||
// storeId: json["storeId"],
|
||||
// categoryId: json["categoryId"],
|
||||
// productTypeId: json["productTypeId"],
|
||||
// timeSlotId: json["timeSlotId"],
|
||||
// productImages: List<ProductImage>.from(json["productImages"].map((x) => ProductImage.fromJson(x))),
|
||||
// category: Category.fromJson(json["category"]),
|
||||
// productTags: List<ProductTag>.from(json["productTags"].map((x) => ProductTag.fromJson(x))),
|
||||
// zones: List<dynamic>.from(json["zones"].map((x) => x)),
|
||||
// productReview: List<dynamic>.from(json["ProductReview"].map((x) => x)),
|
||||
// );
|
||||
|
||||
// Map<dynamic, dynamic> toJson() => {
|
||||
// "id": id,
|
||||
// "name": name,
|
||||
// "description": description,
|
||||
// "additionalInfo": additionalInfo,
|
||||
// "brand": brand,
|
||||
// "basePrice": basePrice,
|
||||
// "discountPrice": discountPrice,
|
||||
// "stock": stock,
|
||||
// "quantity": quantity,
|
||||
// "unit": unit,
|
||||
// "slug": slug,
|
||||
// "averageRating": averageRating,
|
||||
// "isInStock": isInStock,
|
||||
// "isActive": isActive,
|
||||
// "createdAt": createdAt.toIso8601dynamic(),
|
||||
// "updatedAt": updatedAt.toIso8601dynamic(),
|
||||
// "storeId": storeId,
|
||||
// "categoryId": categoryId,
|
||||
// "productTypeId": productTypeId,
|
||||
// "timeSlotId": timeSlotId,
|
||||
// "productImages": List<dynamic>.from(productImages.map((x) => x.toJson())),
|
||||
// "category": category.toJson(),
|
||||
// "productTags": List<dynamic>.from(productTags.map((x) => x.toJson())),
|
||||
// "zones": List<dynamic>.from(zones.map((x) => x)),
|
||||
// "ProductReview": List<dynamic>.from(productReview.map((x) => x)),
|
||||
// };
|
||||
// }
|
||||
|
||||
class Category {
|
||||
dynamic id;
|
||||
dynamic name;
|
||||
dynamic description;
|
||||
dynamic image;
|
||||
dynamic slug;
|
||||
dynamic level;
|
||||
bool? isActive;
|
||||
DateTime? createdAt;
|
||||
DateTime? updatedAt;
|
||||
dynamic parentCategoryId;
|
||||
dynamic path;
|
||||
dynamic id;
|
||||
dynamic name;
|
||||
dynamic description;
|
||||
dynamic image;
|
||||
dynamic slug;
|
||||
int? 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,
|
||||
});
|
||||
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(
|
||||
factory Category.fromJson(Map<dynamic, dynamic> json) => Category(
|
||||
id: json["id"],
|
||||
name: json["name"],
|
||||
description: json["description"],
|
||||
@@ -138,9 +499,9 @@ class Category {
|
||||
updatedAt: DateTime.parse(json["updatedAt"]),
|
||||
parentCategoryId: json["parentCategoryId"],
|
||||
path: json["path"],
|
||||
);
|
||||
);
|
||||
|
||||
Map<dynamic, dynamic> toJson() => {
|
||||
Map<dynamic, dynamic> toJson() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"description": description,
|
||||
@@ -152,97 +513,34 @@ class Category {
|
||||
"updatedAt": updatedAt,
|
||||
"parentCategoryId": parentCategoryId,
|
||||
"path": path,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
class ProductImage {
|
||||
dynamic id;
|
||||
dynamic url;
|
||||
bool? isDefault;
|
||||
dynamic productId;
|
||||
dynamic id;
|
||||
dynamic url;
|
||||
bool? isDefault;
|
||||
dynamic productId;
|
||||
|
||||
ProductImage({
|
||||
this.id,
|
||||
this.url,
|
||||
this.isDefault,
|
||||
this.productId,
|
||||
});
|
||||
ProductImage({
|
||||
this.id,
|
||||
this.url,
|
||||
this.isDefault,
|
||||
this.productId,
|
||||
});
|
||||
|
||||
factory ProductImage.fromJson(Map<dynamic, dynamic> json) => ProductImage(
|
||||
factory ProductImage.fromJson(Map<dynamic, dynamic> json) => ProductImage(
|
||||
id: json["id"],
|
||||
url: json["url"],
|
||||
isDefault: json["isDefault"],
|
||||
productId: json["productId"],
|
||||
);
|
||||
);
|
||||
|
||||
Map<dynamic, dynamic> toJson() => {
|
||||
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,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -109,16 +109,20 @@ class AddtocartProvider extends ChangeNotifier {
|
||||
|
||||
return result.fold(
|
||||
(error) {
|
||||
print("dsjfgkjhkdfgdkjfhg");
|
||||
isLoaddcartItem = false;
|
||||
notifyListeners();
|
||||
},
|
||||
(response) {
|
||||
print("dsjfgkjhkdjsfjkdhfsgfgdkjfhg");
|
||||
allitem = response!;
|
||||
isLoaddcartItem = false;
|
||||
notifyListeners();
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e)
|
||||
{
|
||||
print("sfddsfdfff");
|
||||
isLoaddcartItem = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -360,7 +360,8 @@ class ProductProvider extends ChangeNotifier {
|
||||
int get quantity => _quantity;
|
||||
double get totalPrice => _totalPrice;
|
||||
|
||||
void setProductPrice(double price) {
|
||||
void setProductPrice(double price)
|
||||
{
|
||||
_unitPrice = price;
|
||||
_totalPrice = _unitPrice * _quantity;
|
||||
notifyListeners();
|
||||
|
||||
@@ -93,6 +93,8 @@ class ProductRepo {
|
||||
|
||||
AllCartItems allCartItems = allCartItemsFromJson(response.toString());
|
||||
|
||||
print("jdfgjkdf${allCartItems}");
|
||||
|
||||
return right(allCartItems);
|
||||
} on DioException catch (e) {
|
||||
print("sdkjfkjdkfjgjfdjg");
|
||||
|
||||
@@ -213,12 +213,15 @@ class _MycartState extends State<Mycart> {
|
||||
|
||||
Widget cartItems() {
|
||||
return Consumer<AddtocartProvider>(builder: (context, provider, child) {
|
||||
print("djkhsfjh ${provider.allitem.items}");
|
||||
if (provider.isLoaddcartItem) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 120),
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
} else if (provider.allitem != null) {
|
||||
} else if (provider.allitem == null) {
|
||||
return Center(child: Text('🛒 Your Front Shop Cart is empty'));
|
||||
} else if (provider.allitem.items == null) {
|
||||
return Center(child: Text('🛒 Your Front Shop Cart is empty'));
|
||||
} else {
|
||||
return ListView.separated(
|
||||
@@ -229,83 +232,119 @@ class _MycartState extends State<Mycart> {
|
||||
child: const Divider(thickness: 1),
|
||||
),
|
||||
itemCount: provider.allitem.items!.length,
|
||||
itemBuilder: (context, index) => Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24.w),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.greenAccent.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: AppNetworkImage(
|
||||
width: 50.w,
|
||||
height: 40.h,
|
||||
imageUrl:
|
||||
'https://i.pinimg.com/originals/a5/f3/5f/a5f35fb23e942809da3df91b23718e8d.png',
|
||||
backGroundColor: APPCOLOR.bgGrey,
|
||||
radius: 10,
|
||||
),
|
||||
),
|
||||
// Image.asset(product.image, width: 50.w, height: 40.h),
|
||||
itemBuilder: (context, index) {
|
||||
var items = provider.allitem.items![index];
|
||||
|
||||
16.horizontalSpace,
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Vegitables and Fruits",
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
|
||||
print("kdfgdjfgkj ${items}");
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.w),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.greenAccent.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
5.verticalSpace,
|
||||
Text(
|
||||
'1kg, 10\$',
|
||||
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
|
||||
child: AppNetworkImage(
|
||||
width: 60.w,
|
||||
height: 70.h,
|
||||
imageUrl: items.product!.productImages!.first.url ?? " ",
|
||||
backGroundColor: APPCOLOR.bgGrey,
|
||||
radius: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
CustomIconButton(
|
||||
width: 20.w,
|
||||
height: 20.h,
|
||||
onPressed: () {},
|
||||
icon: SvgPicture.asset(
|
||||
APPASSETS.removeIcon,
|
||||
fit: BoxFit.none,
|
||||
),
|
||||
// Image.asset(product.image, width: 50.w, height: 40.h),
|
||||
|
||||
16.horizontalSpace,
|
||||
Container(
|
||||
width: 150.w,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
items.product!.name ?? "",
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
|
||||
),
|
||||
5.verticalSpace,
|
||||
Text(
|
||||
items.product!.unit ?? "",
|
||||
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"\$${items.product!.discountPrice ?? ""} ",
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: context.customSemiBold(Colors.black, 12),
|
||||
),
|
||||
Text(
|
||||
"\$${items.product!.basePrice ?? ""}",
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: context
|
||||
.customMedium(
|
||||
Colors.grey.withOpacity(0.8),
|
||||
12,
|
||||
)
|
||||
.copyWith(
|
||||
decoration: TextDecoration.lineThrough,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
CustomIconButton(
|
||||
width: 14.w,
|
||||
height: 14.h,
|
||||
onPressed: () {
|
||||
// provider.decreaseQuantity(items);
|
||||
},
|
||||
icon: SvgPicture.asset(
|
||||
APPASSETS.removeIcon,
|
||||
fit: BoxFit.none,
|
||||
),
|
||||
backgroundColor: APPCOLOR.appGreen,
|
||||
),
|
||||
backgroundColor: APPCOLOR.appGreen,
|
||||
),
|
||||
16.horizontalSpace,
|
||||
Text(
|
||||
"10",
|
||||
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
|
||||
),
|
||||
16.horizontalSpace,
|
||||
CustomIconButton(
|
||||
width: 20.w,
|
||||
height: 20.h,
|
||||
onPressed: () {},
|
||||
icon: SvgPicture.asset(
|
||||
APPASSETS.addIcon,
|
||||
fit: BoxFit.none,
|
||||
5.horizontalSpace,
|
||||
Text(
|
||||
items.quantity.toString(),
|
||||
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
|
||||
),
|
||||
backgroundColor: APPCOLOR.appGreen,
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
).animate(delay: (100 * index).ms).fade().slideX(
|
||||
duration: 300.ms,
|
||||
begin: -1,
|
||||
curve: Curves.easeInSine,
|
||||
5.horizontalSpace,
|
||||
CustomIconButton(
|
||||
width: 14.w,
|
||||
height: 14.h,
|
||||
onPressed: () {
|
||||
// provider..increaseQuantity(items);
|
||||
},
|
||||
icon: SvgPicture.asset(
|
||||
APPASSETS.addIcon,
|
||||
fit: BoxFit.none,
|
||||
),
|
||||
backgroundColor: APPCOLOR.appGreen,
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
).animate(delay: (100 * index).ms).fade().slideX(
|
||||
duration: 300.ms,
|
||||
begin: -1,
|
||||
curve: Curves.easeInSine,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -321,7 +360,7 @@ class _MycartState extends State<Mycart> {
|
||||
);
|
||||
} else if (provider.allitem == null) {
|
||||
return Center(child: Text('🛒 Your Front Shop Cart is empty'));
|
||||
} else if (provider.allitem.items != null) {
|
||||
} else if (provider.allitem.items == null) {
|
||||
return Center(
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(backgroundColor: Colors.green),
|
||||
@@ -345,7 +384,9 @@ class _MycartState extends State<Mycart> {
|
||||
trailing: Icon(Icons.arrow_forward_ios),
|
||||
onTap: () {},
|
||||
),
|
||||
SummaryRow(label: 'Item Total', value: '\$24'),
|
||||
SummaryRow(
|
||||
label: 'Item Total',
|
||||
value: '\$22'),
|
||||
SummaryRow(label: 'Discount', value: '\$2'),
|
||||
SummaryRow(label: 'Delivery Free', value: 'Free', isGreen: true),
|
||||
Divider(),
|
||||
|
||||
Reference in New Issue
Block a user