I am developing one chat app and I am adding data to chatList which is the list of model and I am getting the newest data from the backend like when I call API it will give the last message so I need to get data from pagination without using any lazy loading method or something so for that I need to call API when I get data to get more data and my list is reverse list (I have UI different so I can’t use reverse property in listview) so I need to insert data to first index like this list.insertAll(0,data)
but when I do that my list is automatically scrolled but when I use list.add()
it is not automatically scrolling.
I have tried most of the methods and scroll physics even I have made one custom scroll physics which remains scroll when inserting data but nothing works in my project I have created on demo project and it is working in that.
2
Answers
Can you try the following?
Add this Scrollcontroller to your widget.
Add the controller to your ListView (or whatever you use)
Lets first try with a button.
Just try to add Controller with "keepScrollOffset" property see if it works.
Example
Use this statement while adding data to list