We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi i have problem , when call a Future function from outside of Scoped Model ,that is run and run ... how can i call that just for run once ?
//// function in Scoped model /////
Future fetchSelectedProducts(String categoryid) async { print("Run Fetch for $categoryid"); selectedProductData.clear(); isLoading = true; notifyListeners(); final response = await http.get('https://....'); List<dynamic> data = json.decode(response.body); ProductModel products = ProductModel(); data.forEach((dynamic protdata) { products = ProductModel( product_id: protdata['product_id'], product_name: protdata['product_name'], product_category: protdata['product_category'], product_des: protdata['product_des'], product_color: protdata['product_color'], product_size: protdata['product_size'], product_barcode: protdata['product_barcode'], product_image: protdata['product_image'], product_count: protdata['product_count'], product_price_buy: protdata['product_price_buy'], product_price_sell: protdata['product_price_sell']); if (products.product_category == categoryid) { selectedProductData.add(products); print("Found:${products.product_category}"); } else print("NotFound"); notifyListeners(); }); isLoading = false; notifyListeners(); return productData; }
//// call fetchSelectedProducts function in outside widget ////
@override Widget build(BuildContext context) { if (widget.currentcategoryID == "0") { return Container( child: Text("Show All Products"), ); } else { runFetchSelectetProduct(widget.currentcategoryID); print( "Run GridView Product lentgh : ${widget.model.selectedProductData.length} "); return Container( child: Text("Show ${widget.currentcategoryID} Product"), ); } } }
runFetchSelectetProduct(categoryid) { widget.model.fetchSelectedProducts(categoryid); print("Run Fetch Selected Product Id:$categoryid"); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi
i have problem , when call a Future function from outside of Scoped Model ,that is run and run ...
how can i call that just for run once ?
//// function in Scoped model /////
//// call fetchSelectedProducts function in outside widget ////
The text was updated successfully, but these errors were encountered: