i want to retrieve data from firestore that has about 8000 docs, i have created method to get the docs data in a list then i created ListView to display my items but nothing showed...i created the same technique in other collections that has less docs like around 50 docs and it always works. so i don't know is the main problem is retrieving a large amount of docs ?
my code:
class FoodDetailsModel{
late String name; late String caffeine; late String calcium;
FoodDetailsModel({
required this.name, required this.caffeine, required this.calcium,
});
FoodDetailsModel.fromJson(dynamic json)
{
name=json['name'];name=json['caffeine'];name=json['calcium'];
}
dynamic toMap()
{
return {
'name':name, 'caffeine':caffeine, 'calcium':calcium,
};
}
}
void getFoodDetails()
{
FirebaseFirestore.instance
.collection('nutrition')
.get()
.then((value){
foodDetailsList = [];
value.docs.forEach((element)
{
foodDetailsList.add(FoodDetailsModel.fromJson(element.data()));
});
emit(getFoodDetailsSuccussState());
});
}
class FoodDetailsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocConsumer<NutritionCubit,LifeStates>(
listener: (context,state){},
builder: (context,state)
{
NutritionCubit.get(context).getFoodDetails();
return Scaffold(
appBar: AppBar(
title: Text('Diets'),
),
body: Column(
children: [
ListView.separated(
itemBuilder: (context,index) => buildFoodDetails(context,NutritionCubit.get(context).foodDetailsList[index]),
itemCount: NutritionCubit.get(context).foodDetailsList.length,
separatorBuilder: (BuildContext context, int index) => SizedBox(height: 20,),
),
],
)
);
},
);
}
}
Widget buildFoodDetails(context,FoodDetailsModel model)
{
return Text(model.name);
}
how can i solve that ?