fixed issue add to cart

This commit is contained in:
2025-02-22 18:59:37 +05:30
parent 2c3e7e2992
commit 27c3a14646
17 changed files with 412 additions and 279 deletions

View File

@@ -293,7 +293,6 @@ class AddtocartProvider extends ChangeNotifier {
};
}
try {
var result = await _homeRepo.paymentOrder(data);
return result.fold(
@@ -497,27 +496,31 @@ class AddtocartProvider extends ChangeNotifier {
);
},
(response) async {
print("kldfjghlkjfgkljh");
await getItemCards(context);
cartItems.add(productId); // Add product to cart
// Fluttertoast.showToast(
// msg: "Added to cart successfully!",
// toastLength: Toast.LENGTH_SHORT,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.green,
// textColor: Colors.white,
// fontSize: 14.0,
// );
cartItems.add(productId);
iscardAdded = true;
notifyListeners(); // Update UI after adding to cart
notifyListeners();
},
);
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("Something went wrong"),
backgroundColor: Colors.red,
),
Fluttertoast.showToast(
msg: "Insufficient stock!",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 14.0,
);
context.showLoader(show: false);
await getItemCards(context);
// isLoadingCart = false;
// iscardAdded = true;
// isLoadings[productId] = false;
notifyListeners();
} finally {
isLoadingCart = false;
isLoadings[productId] = false;