Querying By Categories
besides that you can query your products for the whole store, you can also query with specific category in your store using category()
, like this:
Using await
/async
:
List<Product> allProducts = await YouCan.instance.categories.category('YOUR CATEGORY ID').products.all();
Using A FutureBuilder
:
FutureBuilder<List<Product>>(
future: YouCan.instance.categories.category('YOUR CATEGORY ID').products.all(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Text(snapshot.data);
} else if (snapshot.hasError) {
return Text("Error: ${snapshot.error}");
} else {
return CircularProgressIndicator();
}
},
),