addProductInformation
This commit is contained in:
@@ -304,12 +304,13 @@ class ProductProvider extends ChangeNotifier {
|
||||
Set<String> cartItems = {};
|
||||
Map<String, bool> isLoading = {};
|
||||
|
||||
bool isLoadingCart=false;
|
||||
bool iscardAdded=false;
|
||||
bool isLoadingCart = false;
|
||||
bool iscardAdded = false;
|
||||
|
||||
Future<void> addToCart(BuildContext context, String productId,int quantity) async {
|
||||
Future<void> addToCart(
|
||||
BuildContext context, String productId, int quantity) async {
|
||||
//if (cartItems.contains(productId)) return; // Prevent duplicate additions
|
||||
isLoadingCart=true;
|
||||
isLoadingCart = true;
|
||||
isLoading[productId] = true;
|
||||
notifyListeners(); // Notify UI to show loading indicator
|
||||
|
||||
@@ -337,7 +338,7 @@ isLoadingCart=true;
|
||||
textColor: Colors.white,
|
||||
fontSize: 14.0,
|
||||
);
|
||||
iscardAdded=true;
|
||||
iscardAdded = true;
|
||||
notifyListeners(); // Update UI after adding to cart
|
||||
},
|
||||
);
|
||||
@@ -349,7 +350,7 @@ isLoadingCart=true;
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
isLoadingCart=false;
|
||||
isLoadingCart = false;
|
||||
isLoading[productId] = false;
|
||||
notifyListeners(); // Ensure UI updates after operation
|
||||
}
|
||||
@@ -360,7 +361,6 @@ isLoadingCart=true;
|
||||
|
||||
Future<void> addToWithCart(BuildContext context, String productId,
|
||||
BestDeal bestdealproduct, url) async {
|
||||
|
||||
isLoading[productId] = true;
|
||||
notifyListeners();
|
||||
|
||||
@@ -393,10 +393,11 @@ isLoadingCart=true;
|
||||
notifyListeners(); // Update UI after adding to cart
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e)
|
||||
{
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text("Something went wrong"),
|
||||
content: Text("Product already added"),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
@@ -406,13 +407,11 @@ isLoadingCart=true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<ProductDatum> productDatum = [];
|
||||
String productDatumlastImageurl = '';
|
||||
|
||||
Future<void> addToCartWithWishlist(BuildContext context, String productId,ProductDatum productdataum,
|
||||
url) async {
|
||||
|
||||
Future<void> addToCartWithWishlist(BuildContext context, String productId,
|
||||
ProductDatum productdataum, url) async {
|
||||
isLoading[productId] = true;
|
||||
notifyListeners();
|
||||
|
||||
@@ -458,11 +457,6 @@ isLoadingCart=true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool isWishListItemLoadingg = true;
|
||||
|
||||
List<WishListItem> wishListItem = [];
|
||||
|
||||
Reference in New Issue
Block a user