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

@@ -36,6 +36,7 @@ class ProductProvider extends ChangeNotifier {
bool hasMore = true;
bool iscroll = true;
Future<void> gettAllProduct(
BuildContext context, String id, bool status, String search) async {
if (isLoadingg || !hasMore) return;
@@ -132,12 +133,13 @@ class ProductProvider extends ChangeNotifier {
ProductDetailsData productDetails = ProductDetailsData();
bool isProductLoading = true;
Future<void> getProduuctDetails(BuildContext context, String id) async {
Future<void> getProduuctDetails(
BuildContext context, String id, int quantity, String price) async {
var data = {};
productDetails = ProductDetailsData();
isProductLoading = true;
quantitys = 1;
_totalPrice = 0.0;
quantitys = quantity;
_totalPrice = quantity * (double.parse(price));
notifyListeners();
var result = await _homeRepo.getProductDetails(data, context, id);
@@ -435,11 +437,13 @@ class ProductProvider extends ChangeNotifier {
},
);
} 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,
);
} finally {
isLoadingCart = false;