Querying By Pages
you can query your products by pages, using the pagination()
method
YouCan.instance.products.pagination(2);
Now you can fetch for this specific query using the all()
, in this example, let's say we want to get the all products in the page 2 :
Using await
/async
:
List<Product> secondPageProducts = await YouCan.instance.products.pagination(2).all();
Using A FutureBuilder
:
FutureBuilder<List<Product>>(
future: YouCan.instance.products.pagination(2).all(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Text(snapshot.data);
} else if (snapshot.hasError) {
return Text("Error: ${snapshot.error}");
} else {
return CircularProgressIndicator();
}
},
),