fixed issue add to cart
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user