'how to add elements to Listview.builder without rebuilding all the previous items
i use Listview.builder with a List of items in flutter , when the user scroll down i listen the the scroll controller than i get more data from firebase Firestore
the problem that when more data added to the itemlist all the previous items of the Listview.builder rebuilded automaticaly
ex : the list.lenght is 50 ,when i scroll down i get 20 more items and add them to the item list , the 50 previous item are reubilded automaticaly (like the image ) enter image description here
this make the app bugging some times
any help ?
this is my Listview.builder code
Selector<postsPage_modelView,Tuple2<List<Post>,bool>>(
selector: (_,provider)=>Tuple2(provider.postsList, provider.isLoading),
builder: (_,data,__)=>ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: data.item1.length+1,
itemBuilder: (context,index){
if(index == data.item1.length){
if(data.item2) {
return const Center(
child: CircularProgressIndicator()
);
}
return const Center();
}
Post tmp = data.item1[index];
return PostItem(post: tmp);
},
),
),
thank you all
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|