how can i get random item something mix everytime user open the app. right now i having a gridview that show item but not randomly. i just get all of the data in firestore and show it into gridview with unlimited length of item that look like this
@override
Widget build(BuildContext context) {
final productProvider = Provider.of<ProductProvider>(context);
List<Product> productsList = productProvider.products();
return Column(
children: [
Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'Suggestion Products',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600),
),
TextButton(
onPressed: () {
Navigator.of(context).pushNamed(
FeedsScreen.routeName,
arguments: 'popular',
);
},
child: const Text('view all')),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: SizedBox(
width: double.infinity,
child: Column(
children: [
GridView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: productsList.length,
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 2 / 3,
mainAxisSpacing: 1,
crossAxisSpacing: 15),
itemBuilder: (ctx, i) {
return ChangeNotifierProvider.value(
value: productsList[i],
child: const MainProduct(),
);
},
),
],
),
),
),
],
),
],
);
}
and how can i achieve an suggestion product base on what user history search. kinda look like some o ecommerce app do. when i search for a computer in the app. in the suggestion will suggest me some related product. thanks
Aucun commentaire:
Enregistrer un commentaire